Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Unable to find by id? #4

Closed
msaffitz opened this issue May 29, 2012 · 1 comment
Closed

Unable to find by id? #4

msaffitz opened this issue May 29, 2012 · 1 comment

Comments

@msaffitz
Copy link

I'm trying to find by an ObjectId, but it looks like it's getting converted to a string and thus not returning any documents from the DB.

Simple repo:

Mongorito = require 'mongorito'
ObjectId = require('mongolian').ObjectId

Mongorito.connect ['mongo://...@.../...']

class Doc

Doc = Mongorito.bake Doc

Doc.find( _id: '...', (err, doc) -> console.log doc.length ) // returns 0
Doc.find( _id: new ObjectId('...'), (err, doc) -> console.log doc.length ) // returns 0
Doc.find( title: 'foo', (err,doc) -> console.log doc.length ) // returns 1 (success)
@vadimdemedes
Copy link
Owner

Update pushed, did a massive code refactoring and added ability to query by _id. Warning, you should add constructor to all your models now:

class Doc
  constructor: -> super # this line is required

Anything else stayed as it was. Thank you for reporting an issue!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants