-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find on Schema only ever returns 1 record #47
Comments
I will need to double check, but my guess is I am defaulting to single results for statics. I should do something smarter but, if you add a query parameter single=false it should work. I am thinking I should add a function configuration for this, because its a little hard to determine... var inventorySchema = models.schema.inventory;
inventorySchema.statics.findByStoreId = function findByStoreId(q, term){
return this.find({'store_id': parseInt(term)});
}
inventorySchema.statics.findByStoreId.single = false
mongoose.model('inventory', inventorySchema); I will make that work shortly. But try the first suggestion. |
Justin, Thanks for the ever speedy response. How would I change my static to include that query parameter? I wasn't able Cheers Andre LeFort On Mon, Apr 20, 2015 at 1:50 PM, Justin notifications@github.com wrote:
|
Hmm, that still returns only 1 record. Here is my url http://192.168.33.11:3000/rest/inventory/finder/findByStoreId/112?single=false |
sugar, than its a bug. I'll try to get to it tonight. |
Thanks Justin. |
So I just wrote a test, that I thought would fail but it doesn't... What version are you using? |
Justin, Let's mark this complete, I looked at my code with fresh eyes and noticed a silly typo. Cheers for the help! All works well, as per your examples in this thread. |
Ahh... I think I found it .. Here is an example (soon to be added to mers documentation by some endeavoring soul, or me). BlogPostSchema.statics.findTitleLikeInject = function findTitleLike(params$) {
//shifting the param keeps it from from being descended.
var search = params$.shift();
return this.find({title: new RegExp(search, 'i')});
} Let me know if this works for you. |
yay, not a bug! |
I am running a find on a schema, and when I run the find command in Mongo (via Robomongo for testing), I get all 112 records....when I do a find on the same schema in Mers, I only get 1 record instead of the 112.
I suspect I am missing something in my code, but I don't know.
Mongo find:
and my mers code:
The text was updated successfully, but these errors were encountered: