You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically if I have a field with unique:true then trying to fetch all results returns a random amount of items. I have 4013 items in the db. Here's the schema.
var Order = new Schema({
code: {
type: String,
unique: true
},
...
});
Now run some queries:
Order.find().exec(function(err, orders) {
console.log(orders.length); // always 101
})
Order.find().limit(100000).exec(function(err, orders) {
console.log(orders.length); // varies, sometimes 1150, 1790, 2046 - never more
})
Now if I remove the 'unique: true' from schema it will always return the total amount:
Here's my guess - there are duplicate items in there and Mongo is freaking out and choking in a sync way - it never gets higher than 2046 whichI bet is a duplicate - a few times it will stop early so I think it a) stops on duplicate and b) it does so sync or not in same "process" as fetching and will sometimes stop earlier. I bet if I remove the dups it will prob work though I wish there was some errors. Does that sound about right?
Basically if I have a field with unique:true then trying to fetch all results returns a random amount of items. I have 4013 items in the db. Here's the schema.
Now run some queries:
Now if I remove the 'unique: true' from schema it will always return the total amount:
Any idea as to why this behavior occurs? afaik the codes are all unique (orders from a merchant). This is tested on 3.8.6, 3.8.8
The text was updated successfully, but these errors were encountered: