const getRecentCommunities = (): Array<DBCommunity> => { return db .table('communities') .orderBy({ index: db.desc('createdAt') }) .filter(community => db.not(community.hasFields('deletedAt'))) .limit(100) .run(); }
@computed get foundItems() { let filteredItems = this.props.items.filter(item => compareFuzzy(item.name, this.search)); let orderedItems = orderBy(filteredItems, [i => i.name === this.search], ['desc']); return orderedItems; }
const getLastTwoCoreMetrics = (): Promise<Array<DBCoreMetric>> => { return ( db .table('coreMetrics') .orderBy(db.desc('date')) .run() // send back the most recent 2 records .then(results => results.slice(0, 2)) ); }
simpleQuery() { // eslint-disable-next-line prefer-template const inlineWhereConditions = []; const commonQuery = this.rewriteInlineWhere(() => this.commonQuery(), inlineWhereConditions); return `${commonQuery} ${this.baseWhere(this.allFilters.concat(inlineWhereConditions))}` + this.groupByClause() + this.baseHaving(this.measureFilters) + this.orderBy() + this.groupByDimensionLimit(); }
/* * Create a data source */ create(source, data = {}, sort = []) { let database = this.read(source); database.push(_.merge({}, data, {id: hasher(data)})); // Sort if we have to if (!_.isEmpty(sort)) database = _.orderBy(database, ...sort); // Dump results this.yaml.dump(path.resolve(this.base, `${source}.yml`), _.uniqBy(database, 'id')); return this.read(source, {id: hasher(data)}); }
this.morphMany( GLOBALS[globalId], details.via, `${definition.collectionName}` ).query(qb => { qb.where(filter, name).orderBy('order'); })
createSelector( ( state, siteId, status, order = 'asc' ) => { const comments = state.comments.items ?? {}; const parsedComments = Object.keys( comments ) .filter( ( key ) => parseInt( key.split( '-', 1 ), 10 ) === siteId ) .reduce( ( list, key ) => [ ...list, ...comments[ key ] ], [] ); return status ? orderBy( filterCommentsByStatus( parsedComments, status ), 'date', order ) : orderBy( parsedComments, 'date', order ); }, ( state ) => [ state.comments.items ] )
const sortEntries = entries => { return orderBy(entries, [e => e && e.name[0] === '.', e => e && e.name.toLowerCase()], ['desc', 'asc']); }
const formatPolymorphicPopulate = ({ assoc, prefix = '' }) => { // MorphTo side. if (assoc.related) { return { [`${prefix}${assoc.alias}.related`]: () => {} }; } // oneToMorph or manyToMorph side. // Retrieve collection name because we are using it to build our hidden model. const model = strapi.db.getModelByAssoc(assoc); return { [`${prefix}${assoc.alias}.${model.collectionName}`]: function(query) { query.orderBy('created_at', 'desc'); }, }; }
_(loadCacheFile(config.toolingRouter)) .map(route => _.merge({}, route, { closeness: _.indexOf(pathsToRoot(), route.route), })) .filter(route => route.closeness !== -1) .orderBy('closeness') .thru(routes => routes[0]) .value()
createSelector( ( state, siteId, postId ) => { const revisions = get( state.posts.revisions.diffs, [ siteId, postId, 'revisions' ] ); return orderBy( revisions, [ 'post_modified_gmt', 'id' ], [ 'desc', 'desc' ] ); }, ( state ) => [ state.posts.revisions.diffs ] )
const getThreadsByCommunity = (communityId: string): Promise<Array<DBThread>> => { return db .table('threads') .between([communityId, db.minval], [communityId, db.maxval], { index: 'communityIdAndLastActive', leftBound: 'open', rightBound: 'open', }) .orderBy({ index: db.desc('communityIdAndLastActive') }) .filter(thread => db.not(thread.hasFields('deletedAt')).and(NOT_WATERCOOLER(thread))) .run(); }
_(apps) .filter(app => app.closeness !== -1) .orderBy('closeness') .thru(apps => apps[0]) .value()
this.morphMany( GLOBALS[globalId], details.via, `${definition.collectionName}` ).query(qb => { qb.where(filter, name).orderBy('order'); })