I'm using mongo 2.4.
I have a collection which has these two entries:
> db.collection.find({domain: "pow.com"})
{ "_id" : ObjectId("577ee9ec6f66304109769855"), "domain" : "pow.com", "mImp" : NumberLong(38), "oImp" : NumberLong(38), "vImp" : NumberLong(120), "date" : "Thu Jul 07 2016 16:46:52 GMT-0700 (PDT)", "id" : NumberLong(3847146) }
{ "_id" : ObjectId("577ef4c44df54be7247eb497"), "domain" : "pow.com", "mImp" : NumberLong(38), "oImp" : NumberLong(38), "vImp" : NumberLong(120), "date" : ISODate("2016-10-01T00:00:00Z"), "id" : NumberLong(3847146) }
I've tried to run these queries and everytime I get no data back:
> db.collection.find({"vImp": NumberLong(38)});
> db.collection.find({vImp: NumberLong(38)});
> db.collection.find({vImp: 38});
> db.collection.find(vImp: 38)
I've tried to google around, but it seems like this should be working....
NumberLong. The mongo shell treats all numbers as floating-point values by default. The mongo shell provides the NumberLong() wrapper to handle 64-bit integers. The NumberLong() wrapper accepts the long as a string: NumberLong("2090845886852")
To query data from MongoDB collection, you need to use MongoDB's find() method.
MongoDB Query is a way to get the data from the MongoDB database. MongoDB queries provide the simplicity in process of fetching data from the database, it's similar to SQL queries in SQL Database language.
I believe you are missing the "" around 38.
On MongoDB shell version: 3.0.14
db.users.find({"id":NumberLong("853969028494368768")})
in your case
db.collection.find({"vImp": NumberLong("38")})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With