Mongodb – Trying to get one element from an array using mongoose
I am trying to get randomly one item from an array using mongoose, I use .aggregate: const winner = await gSchema.aggregate( [ { "$unwind": "$Users" }, { "$sample": { "size": 1 } } ] ) I console.log(winner) I get: […