since(searchName, field, value, w) { if (!value) return w; return w[field.target.field] = { [Op.gt]: dateToDateTime(value) }; }
db.Video.findAll({ where: { yt_video_key: { [Op.not]: null }, [Op.or]: [ { status: [STATUSES.LIVE, STATUSES.UPCOMING] }, { status: STATUSES.MISSING, live_schedule: { [Op.gt]: utcDate.clone().subtract(3, 'hour') } }, ], }, order: [ ['status', 'ASC'], ['updated_at', 'ASC'], ], limit: 50, }).catch((err) => { // Catch and log db error log.error('videoStatusAPI() Unable to fetch videos for tracking', { error: err.toString() }); // Return empty list, so the succeeding process for upcoming videos wil continue return []; })
/* ========================== STOCK SECTION =========================== */ findAllForRange(stocks, start, end, cb) { let startDate = new Moment(start, "YYYY-MM-DD"); let endDate = new Moment(end, "YYYY-MM-DD"); db.StockHistory.findAll({where: {symbol: {[Op.in]:stocks}, timestamp: { [Op.lt]: Moment(end, 'YYYY-MM-DD').unix(), [Op.gt]: Moment(start, 'YYYY-MM-DD').unix() }}, order: [['timestamp','ASC']] }).then(results => { let grouped = {}; results.forEach(function(row) { if(!grouped[row.symbol]) { grouped[row.symbol] = []; } grouped[row.symbol].push(row); }); cb(grouped); }); }
autoUpdate: { [Op.gt]: 0 }
/** * Builds query to get records where the value of the field is [<,<=,>,>=,!=] to the value. */ const buildComparatorQuery = function({ field, value, comparator, isDate = false, }) { const sqlComparators = { gt: Op.gt, ge: Op.gte, lt: Op.lt, le: Op.lte, ne: Op.ne, sa: Op.gt, eb: Op.lt, }; const sqlComparator = sqlComparators[comparator]; if (isDate) { return { [Op.and]: [{ name: field }, formDateComparison(sqlComparator, value)], }; } else { return { name: field, value: { [sqlComparator]: value } }; } }
/** * Adds all the playerIds to all ongoing/upcoming competitions of a specific group. * * This should be executed when players are added to a group, so that they can * participate in future or current group competitions. */ async function addToGroupCompetitions(groupId, playerIds) { // Find all upcoming/ongoing competitions for the group const competitions = await Competition.findAll({ attributes: ['id'], where: { groupId, endsAt: { [Op.gt]: new Date() } } }); const participations = []; // Build an array of all (supposed) participations competitions.forEach(c => { playerIds.forEach(playerId => { participations.push({ playerId, competitionId: c.id }); }); }); // Bulk create all the participations, ignoring any duplicates await Participation.bulkCreate(participations, { ignoreDuplicates: true }); }
/** * Removes all the playerIds from all ongoing/upcoming competitions of a specific group. * * This should be executed when players are removed from a group, so that they are * no longer participating in future or current group competitions. */ async function removeFromGroupCompetitions(groupId, playerIds) { // Find all upcoming/ongoing competitions for the group const competitionIds = ( await Competition.findAll({ attributes: ['id'], where: { groupId, endsAt: { [Op.gt]: new Date() } } }) ).map(c => c.id); await Participation.destroy({ where: { competitionId: competitionIds, playerId: playerIds } }); }
action: constant_1.modelAction.check_in, create_date: { [Op.gt]: startTime,
books_id: resData.books_id, book_id: { [Op.gt]: resData.book_id
describe('buildComparatorQuery Tests', () => { test('Should return sequelize Greater Than query given a key, value, and gt', () => { const expectedResult = { name: 'foo', value: { [Op.gt]: 'bar' } }; let observedResult = sqlQB.buildComparatorQuery({ field: 'foo', }); test('Should return SQL Greater Than query given a key, value, and sa', () => { const expectedResult = { name: 'foo', value: { [Op.gt]: 'bar' } }; let observedResult = sqlQB.buildComparatorQuery({ field: 'foo',
where: { date: { [Op.gt]: new Date(), }, },
autoUpdate: { [Op.gt]: 0 }
/** * Builds query to get records where the value of the field is [<,<=,>,>=,!=] to the value. */ const buildComparatorQuery = function({ field, value, comparator, isDate = false, }) { const sqlComparators = { gt: Op.gt, ge: Op.gte, lt: Op.lt, le: Op.lte, ne: Op.ne, sa: Op.gt, eb: Op.lt, }; const sqlComparator = sqlComparators[comparator]; if (isDate) { return { [Op.and]: [{ name: field }, formDateComparison(sqlComparator, value)], }; } else { return { name: field, value: { [sqlComparator]: value } }; } }
describe('buildComparatorQuery Tests', () => { test('Should return sequelize Greater Than query given a key, value, and gt', () => { const expectedResult = { name: 'foo', value: { [Op.gt]: 'bar' } }; let observedResult = sqlQB.buildComparatorQuery({ field: 'foo', }); test('Should return SQL Greater Than query given a key, value, and sa', () => { const expectedResult = { name: 'foo', value: { [Op.gt]: 'bar' } }; let observedResult = sqlQB.buildComparatorQuery({ field: 'foo',