Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding documents in mongodb collection where a field is equal to given integer value

I would like to find all documents where the field property_id is equal to -549. I tried:

db.getCollection('CollectionName').find({'property_id' : -549 })

This returns no records with a message: "Fetched 0 record(s)."

But I am seeing the document right there where the field property_id is -549. I am not sure what I am doing wrong. The type of field is int32.

Here are the first two fields of the document that I am looking to find with the query

like image 698
Semihcan Doken Avatar asked Nov 25 '25 17:11

Semihcan Doken


1 Answers

Check if there is a space in the field name 'property_id': Try

db.getCollection('CollectionName').find({'\uFEFFproperty_id' : -549 })
like image 200
Semihcan Doken Avatar answered Nov 27 '25 15:11

Semihcan Doken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!