Why i am getting the total count as ZERO even after importing 240 documents succesfully?

Aditya kumar

Actually i was learning MongoDB and in that I got stuck in order to import a JSON file(which is located at Desktop of my laptop)

My JSON file is array of 240 element each of similar type as shown below (I have added two such documents in the array and similarly other 238 documents are of same form are present in the same array) :-

[
  {
    "id": 1,
    "url": "http://www.tvmaze.com/shows/1/under-the-dome",
    "name": "Under the Dome",
    "type": "Scripted",
    "language": "English",
    "genres": [
      "Drama",
      "Science-Fiction",
      "Thriller"
    ],
    "status": "Ended",
    "runtime": 60,
    "premiered": "2013-06-24",
    "officialSite": "http://www.cbs.com/shows/under-the-dome/",
    "schedule": {
      "time": "22:00",
      "days": [
        "Thursday"
      ]
    },
    "rating": {
      "average": 6.5
    },
    "weight": 91,
    "network": {
      "id": 2,
      "name": "CBS",
      "country": {
        "name": "United States",
        "code": "US",
        "timezone": "America/New_York"
      }
    },
    "webChannel": null,
    "externals": {
      "tvrage": 25988,
      "thetvdb": 264492,
      "imdb": "tt1553656"
    },
    "image": {
      "medium": "http://static.tvmaze.com/uploads/images/medium_portrait/0/1.jpg",
      "original": "http://static.tvmaze.com/uploads/images/original_untouched/0/1.jpg"
    },
    "summary": "<p><b>Under the Dome</b> is the story of a small town that is suddenly and inexplicably sealed off from the rest of the world by an enormous transparent dome. The town's inhabitants must deal with surviving the post-apocalyptic conditions while searching for answers about the dome, where it came from and if and when it will go away.</p>",
    "updated": 1529612668,
    "_links": {
      "self": {
        "href": "http://api.tvmaze.com/shows/1"
      },
      "previousepisode": {
        "href": "http://api.tvmaze.com/episodes/185054"
      }
    }
  },
  {
    "id": 2,
    "url": "http://www.tvmaze.com/shows/2/person-of-interest",
    "name": "Person of Interest",
    "type": "Scripted",
    "language": "English",
    "genres": [
      "Drama",
      "Action",
      "Crime"
    ],
    "status": "Ended",
    "runtime": 60,
    "premiered": "2011-09-22",
    "officialSite": "http://www.cbs.com/shows/person_of_interest/",
    "schedule": {
      "time": "22:00",
      "days": [
        "Tuesday"
      ]
    },
    "rating": {
      "average": 9
    },
    "weight": 96,
    "network": {
      "id": 2,
      "name": "CBS",
      "country": {
        "name": "United States",
        "code": "US",
        "timezone": "America/New_York"
      }
    },
    "webChannel": null,
    "externals": {
      "tvrage": 28376,
      "thetvdb": 248742,
      "imdb": "tt1839578"
    },
    "image": {
      "medium": "http://static.tvmaze.com/uploads/images/medium_portrait/163/407679.jpg",
      "original": "http://static.tvmaze.com/uploads/images/original_untouched/163/407679.jpg"
    },
    "summary": "<p>You are being watched. The government has a secret system, a machine that spies on you every hour of every day. I know because I built it. I designed the Machine to detect acts of terror but it sees everything. Violent crimes involving ordinary people. People like you. Crimes the government considered \"irrelevant\". They wouldn't act so I decided I would. But I needed a partner. Someone with the skills to intervene. Hunted by the authorities, we work in secret. You'll never find us. But victim or perpetrator, if your number is up, we'll find you.</p>",
    "updated": 1535507028,
    "_links": {
      "self": {
        "href": "http://api.tvmaze.com/shows/2"
      },
      "previousepisode": {
        "href": "http://api.tvmaze.com/episodes/659372"
      }
    }
  }
]

Also I tried using this command:-
C:\Users\adity>mongoimport --jsonArray --db movie --collection movies --file C:\Users\adity\Desktop\tv-shows.json

And i think the data has been successfully imported as i got this

C:\Users\adity>mongoimport --jsonArray --db movie --collection movies --file C:\Users\adity\Desktop\tv-shows.json
2021-09-29T12:43:37.247+0530    connected to: mongodb://localhost/
2021-09-29T12:43:37.288+0530    240 document(s) imported successfully. 0 document(s) failed to import.

But when i run the following command it is showing me something non-expected outputs:-

C:\WINDOWS\system32>net start mongoDB
The MongoDB Server (MongoDB) service is starting.
The MongoDB Server (MongoDB) service was started successfully.


C:\WINDOWS\system32>mongo
MongoDB shell version v5.0.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("590da209-aceb-4e56-960b-c950384ee3af") }
MongoDB server version: 5.0.3
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
We recommend you begin using "mongosh".
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
---
The server generated these startup warnings when booting:
        2021-09-29T13:39:59.232+05:30: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
        Enable MongoDB's free cloud-based monitoring service, which will then receive and display
        metrics about your deployment (disk utilization, CPU, operation statistics, etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring, run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
WARNING: some history file lines were truncated at 4095 bytes.
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
movie   0.001GB
test    0.000GB
> use movie
switched to db movie
> db.movie.find().count()
0
> db.movie.find().pretty()
>

And I am using Windows OS.

Could someone help me why i am getting the value of count as ZERO??

Jey Raj

The filename is missing.

Use:

mongoimport --jsonArray --db movie --collection movies --file C:\Users\adity\Desktop\yourfilename.json

Instead of:

mongoimport --jsonArray --db movie --collection movies --file C:\Users\adity\Desktop\.

Or cd Desktop in your CMD and provide:

mongoimport --jsonArray --db movie --collection movies --file yourfilename.json

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why i am getting a zero total amount of money?

C# why am I getting zero count back?

Even after initialising, why am I getting this error?

I am getting 'p-calendar' is not a known element error even after importing CalendarModule and adding it to imports in AppModule

Why am i getting null for calculating a total?

Why am I getting zero in the output?

Why am I getting an error that I cannot concat two different datatypes even after casting the fields datatype

I am getting error even after successful output in angular 2 project. Why So?

Javascript: why am i getting NaN even after using parseInt() function?

why am i getting error when importing AudioSegment?

Why am I getting zero when I multiply doubles?

Why am I getting a divide by zero error here?

Why am I always getting a time difference of zero?

Why am I getting java.lang.ArithmeticException: divide by zero

Why am I getting zero in specific rows as a result of this division?

Why am I getting the output of zero when scanning the file for a word?

Getting the total count of all the documents in buckets

Why am I getting inputMismatchException even when using hasNextInt() method?

Why am I not getting the desired output even though no errors?

Why am I getting a pending promise even in .then block?

Even though they are logically the same, why am I getting different outputs?

why am i getting this error even that index is exist?

Why is this not defined if I am importing it?

Why am i getting this error (java.net.BindException: Address already in use: NET_Bind) even after closing the socket?

Why am I getting this error message even after transforming my data set into a ts file for time series analysis?

why i am getting the mysql mode error in the group by clause even after changing its mode to full_group

Why am I getting ErrNoRows("sql: no rows in result set") after inserting into postgres, even when insert was actually successful?

Spark's GraphX: Why am I getting "Joining / Diffing two VertexPartitions with different indexes is slow" even after having persisted involved RDDs

Why am I able to write to and read a tempfile even after closing it?