Started with Mongo
This commit is contained in:
30
server/src/resolvers/Query.js
Normal file
30
server/src/resolvers/Query.js
Normal file
@@ -0,0 +1,30 @@
|
||||
async function feed(parent, args, context, info) {
|
||||
console.log(context);
|
||||
const where = args.filter
|
||||
? {
|
||||
OR: [
|
||||
{ title: { contains: args.filter } },
|
||||
{ description: { contains: args.filter } }
|
||||
]
|
||||
}
|
||||
: {};
|
||||
|
||||
const appointments = await context.mongo.appointment.findMany({
|
||||
where,
|
||||
skip: args.skip,
|
||||
take: args.take,
|
||||
orderBy: args.orderBy
|
||||
});
|
||||
|
||||
const count = await context.mongo.appointment.count({ where });
|
||||
|
||||
return {
|
||||
id: 'main-feed',
|
||||
appointments,
|
||||
count
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
feed
|
||||
};
|
||||
Reference in New Issue
Block a user