I would like to select random documents from a collection. I know that there is a $sample pipeline for aggregation but I was not able to use it. I tried the following:
var pipeline = { sample: { size: 2 } }
var query = new Parse.Query("Questions");
query.aggregate(pipeline)
.then(function(results) {
console.log(results)
})
.catch(function(error) {
console.log(error)
});
It gives the error:
{ Error
at C:\Users\Can\Desktop\Closer\node_modules\parse\lib\node\RESTController.js:320:19
at process._tickCallback (internal/process/next_tick.js:68:7) code: 1, message: undefined }
Aucun commentaire:
Enregistrer un commentaire