Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Gigs from '../../../../collections/Gigs/model';
- const gigs = async (root, { params }, { user }) => {
- try {
- let gigs = [];
- let count = 0;
- if (!user || !user.id) return { gigs, count };
- let query = {};
- // maybe some logic to add fields to query objects here to make sure you only return certain business's gigs vs all gigs
- gigs = await Gigs.find(query).limit(10);
- count = await Gigs.find(query).count();
- console.log({ count, gigs });
- return {
- gigs: gigs || [],
- count: count || 0
- };
- } catch (err) {
- console.log(err);
- }
- };
- export default gigs;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement