daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Liana = require('forest-express-sequelize');
  2. const models = require('../../models');
  3.  
  4. const { Op } = models.Sequelize;
  5.  
  6. Liana.collection('guest', {
  7.   fields: [{
  8.     field: 'googleAccessToken',
  9.     type: 'String',
  10.     get: async (guest) => {
  11.       const user = await guest.getUser({
  12.         include: [{
  13.           model: models.googleSession,
  14.         }],
  15.       });
  16.  
  17.       console.log('===== user', user.googleSession);
  18.       return user && user.googleSession && user.googleSession.accessToken;
  19.     },
  20.     search(query, search) {
  21.       query.include.push({
  22.         model: models.user,
  23.         include: [{
  24.           model: models.googleSession,
  25.         }],
  26.       });
  27.  
  28.       query.where[Op.and][0][Op.or]
  29.         .push(models.sequelize.literal(`"user->googleSession"."accessToken" ILIKE '%${search}%'`));
  30.     },
  31.   }],
  32. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top