Db.people.count({ "email" : {"$exists": 1} }) returning zero records afeter successful import

HI eam,

I have completed import successfully but validating import in DB level is not returning correct value.

Please suggest the solution to fix the issue.

C:\Program Files\MongoDB\Server\3.4\bin>mongoimport -d m201 -c people --drop C:\MongoDB\university\m201\people.json
2019-03-18T11:02:57.872+0000 connected to: localhost
2019-03-18T11:02:57.874+0000 dropping: m201.people
2019-03-18T11:02:59.604+0000 […] m201.people 455KB/21.8MB (2.0%)
2019-03-18T11:03:02.364+0000 [########################] m201.people 21.8MB/21.8MB (100.0%)
2019-03-18T11:03:02.364+0000 imported 50474 documents

C:\Program Files\MongoDB\Server\3.4\bin>mongo

C:\Program Files\MongoDB\Server\3.4\bin>mongo
MongoDB shell version v3.4.20
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.6
WARNING: shell and server versions do not match
Server has startup warnings:
2019-03-16T11:08:43.206+0000 I CONTROL [initandlisten]
2019-03-16T11:08:43.206+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-03-16T11:08:43.206+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-03-16T11:08:43.206+0000 I CONTROL [initandlisten]

show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
m201 0.011GB
use 201
switched to db 201
> db.people.count({ “email” : {"$exists": 1} })
0

Thanks,
Kiran

You get a count of 0 because 0 documents match your query.

If you do db.people.count() you will see how many documents are in your collection.

1 Like

Thanks Steeve, Thanks for the help, I have copied query from lab instructions.

Mongo DB team has to update validation query with correct syntax.

Chapter 1: Introduction

Lab 1.1: Install Course Dependencies

Issue resolved.