0

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" : [

1 Answer 1

3

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 ;)

Not the answer you're looking for? Browse other questions tagged or ask your own question.