UNPKG

desi-mongoose

Version:

A fun and intuitive MongoDB ODM for Node.js with a Hinglish twist

58 lines (57 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DesiAggregation = void 0; class DesiAggregation { constructor() { this.pipeline = []; } milao(lookupConfig) { this.pipeline.push({ $lookup: lookupConfig }); return this; } chuno(fields) { this.pipeline.push({ $project: fields.reduce((acc, field) => ({ ...acc, [field]: 1 }), {}) }); return this; } samooh(groupConfig) { this.pipeline.push({ $group: groupConfig }); return this; } khaaliChodo(skipCount) { this.pipeline.push({ $skip: skipCount }); return this; } sirafDikhao(limitCount) { this.pipeline.push({ $limit: limitCount }); return this; } kramBadlo(sortConfig) { this.pipeline.push({ $sort: sortConfig }); return this; } milaKarGino(field) { this.pipeline.push({ $group: { _id: null, total: { $sum: `$${field}` } } }); return this; } unwind(field) { this.pipeline.push({ $unwind: `$${field}` }); return this; } match(condition) { this.pipeline.push({ $match: condition }); return this; } addFields(fields) { this.pipeline.push({ $addFields: fields }); return this; } getPipeline() { return this.pipeline; } } exports.DesiAggregation = DesiAggregation;