Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
});
}
if (Array.isArray(tags) && tags.length > 0) {
$and.push({
tags: { $in: tags.map(tag => tag.toLowerCase()) }
});
}
if ($and.length) {
findArgs.query = { $and };
}
const data = await entityClass.find(findArgs);
return new ListResponse(data, data.getMeta());
};
.getDriver()
.aggregate(collection, [
...pipeline,
{ $project: { _id: -1, id: 1 } },
{ $skip: (page - 1) * perPage },
{ $limit: perPage }
]);
const [totalCount] = await entityClass.getDriver().aggregate(collection, [
...pipeline,
{
$count: "totalCount"
}
]);
return new ListResponse(
await entityClass.find({ sort, query: { id: { $in: ids.map(item => item.id) } } }),
createPaginationMeta({
page,
perPage,
totalCount: totalCount ? totalCount.totalCount : 0
})
);
};
export default async (root: any, args: Object, context: Object) => {
const Page = context.getEntity("PbPage");
const Category = context.getEntity("PbCategory");
const data = await listPublishedPages({ args, Page, Category });
return new ListResponse(data, data.getMeta());
};