Массив содержит идентификаторы объекта Mongoose. Вот мой код: < /p>
Код: Выделить всё
let isSelectedTrips = ["******", "*****"]// this actually contains trip ids.
const me = await Trips.aggregate([
{
$match: { isPublished: true, _id: { $in: isSelectedTrips } },
},
{
$facet: {
getTrips: [{ $skip: skip }, { $limit: Number(searchlimit) }],
totalDocumentSize: [{ $count: "count" }],
},
},
]);
trips = me[0].getTrips;
totalDocumentSize = me[0].totalDocumentSize[0]?.count || 0;
Вот версия, которая работала: < /p>
Код: Выделить всё
const me = await Trips.find({ _id: { $in: isSelectedTrips }, isPublished: true, });
trips = me;
totalDocumentSize = 3;
Подробнее здесь: https://stackoverflow.com/questions/794 ... ate-method
Мобильная версия