Why Findrandom() Mongoose For Node.js Method Doesn't Work?
Schema: var random = require('mongoose-random'); var productSchema = new mongoose.Schema(...) productSchema.plugin(random, {path: 'r'}); var products = mongoose.model('sportsStor
Solution 1:
And probably solution could be here - see the comments on npm page mongoose-random example .
// if you have an existing collection, it must first by synced.// this will add random data for the `path` key for each doc.
Try
productSchema.syncRandom(function (err, result) {
console.log(result.updated);
});
Post a Comment for "Why Findrandom() Mongoose For Node.js Method Doesn't Work?"