Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import Gigs from '../../../../collections/Gigs/model';
  2.  
  3. const gigs = async (root, { params }, { user }) => {
  4. try {
  5. let gigs = [];
  6. let count = 0;
  7. if (!user || !user.id) return { gigs, count };
  8.  
  9. let query = {};
  10.  
  11. // maybe some logic to add fields to query objects here to make sure you only return certain business's gigs vs all gigs
  12.  
  13. gigs = await Gigs.find(query).limit(10);
  14. count = await Gigs.find(query).count();
  15.  
  16. console.log({ count, gigs });
  17.  
  18. return {
  19. gigs: gigs || [],
  20. count: count || 0
  21. };
  22. } catch (err) {
  23. console.log(err);
  24. }
  25. };
  26.  
  27. export default gigs;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement