sql >> Base de Datos >  >> NoSQL >> MongoDB

¿Por qué findRandom() mangosta para el método node.js no funciona?

Y probablemente la solución podría estar aquí:vea los comentarios en página npm mongoose-random ejemplo .

// if you have an existing collection, it must first by synced.
// this will add random data for the `path` key for each doc.

Prueba

productSchema.syncRandom(function (err, result) {
   console.log(result.updated);
});