Reputation: 23747
I have a document such as:
{ _id: 4e69bbedee97560001000011,
case_id: '5', ... }
If I do:
Case.find {_id : "4e69bbedee97560001000011"}, (err,docs) ->
docs.forEach (item, i) ->
console.log item
It works fine but if I do:
Case.find {case_id : "5"}, (err,docs) ->
docs.forEach (item, i) ->
console.log item
It doesn't. case_id
is a string. Why is this not working? Thanks
It works when I use the mongo console:
db.case_notebooks.find({"case_id" : 5})
{ "_id" : ObjectId("4e69bbedee97560001000011"), "case_id" : 5, "notes" : [
Upvotes: 0
Views: 413
Reputation: 24554
5 != "5" ;)
That´s the reason why it doesn´t match. Try the following:
Case.find {case_id : 5}, (err,docs) ->
docs.forEach (item, i) ->
console.log item
This is equivalent to your console sample ;)
Upvotes: 3