@alipay/faas-db-builder
Advanced tools
Comparing version 1.1.16-alpha.2 to 1.1.16-alpha.3
@@ -20,2 +20,3 @@ import { CondCommandParam, DateToStringCommandParam, IndexOfArrayCommandParam, LetCommandParam, PushCommandParam, QueryChainCommand, SliceCommandParam, SwitchCommandParam } from '../typing'; | ||
import { LetAggregateCommand } from './aggregate/let'; | ||
import { MergeObjectsAggregateCommand } from './aggregate/mergeObjects'; | ||
import { MultiplyAggregateCommand } from './aggregate/multiply'; | ||
@@ -121,2 +122,3 @@ import { NotAggregateCommand } from './aggregate/not'; | ||
multiply(...val: any[]): MultiplyAggregateCommand; | ||
mergeObjects(value: string | AggregateCommand | Array<string | AggregateCommand>): MergeObjectsAggregateCommand; | ||
} | ||
@@ -123,0 +125,0 @@ export declare class Command { |
@@ -1,1 +0,1 @@ | ||
var i=function(o,r,t){if(t||arguments.length===2)for(var n=0,m=r.length,a;n<m;n++){if(a||!(n in r)){if(!a)a=Array.prototype.slice.call(r,0,n);a[n]=r[n]}}return o.concat(a||Array.prototype.slice.call(r))};import{AddAggregateCommand as y}from"./aggregate/add";import{AddToSetAggregateCommand as d}from"./aggregate/addToSet";import{AndAggregateCommand as A}from"./aggregate/and";import{ArrayElemAtAggregateCommand as c}from"./aggregate/arrayElemAt";import{AvgAggregateCommand as w}from"./aggregate/avg";import{CMPAggregateCommand as C}from"./aggregate/cmp";import{ConcatAggregateCommand as s}from"./aggregate/concat";import{CondAggregateCommand as l}from"./aggregate/cond";import{CountAggregateCommand as v}from"./aggregate/count";import{DateToStringAggregateCommand as h}from"./aggregate/dateToString";import{EqAggregateCommand as S}from"./aggregate/eq";import{FirstAggregateCommand as x}from"./aggregate/first";import{IfNullAggregateCommand as M}from"./aggregate/ifNull";import{InAggregateCommand as q}from"./aggregate/in";import{IndexOfArrayAggregateCommand as L}from"./aggregate/indexOfArray";import{IsArrayAggregateCommand as N}from"./aggregate/isArray";import{LastAggregateCommand as T}from"./aggregate/last";import{LetAggregateCommand as E}from"./aggregate/let";import{MultiplyAggregateCommand as P}from"./aggregate/multiply";import{NotAggregateCommand as I}from"./aggregate/not";import{PushAggregateCommand as b}from"./aggregate/push";import{SizeAggregateCommand as z}from"./aggregate/size";import{SliceAggregateCommand as G}from"./aggregate/slice";import{SplitAggregateCommand as O}from"./aggregate/split";import{SubstrAggregateCommand as F}from"./aggregate/substr";import{SubstrBytesAggregateCommand as U}from"./aggregate/substrBytes";import{SwitchAggregateCommand as B}from"./aggregate/switch";import{ToLowerAggregateCommand as R}from"./aggregate/toLower";import{ToUpperAggregateCommand as D}from"./aggregate/toUpper";import{AggregatePipeline as Q}from"./AggregatePipeline";import{ExprCommand as j}from"./query/expr";import{GtAggregateCommand as k}from"./aggregate/gt";import{GteAggregateCommand as H}from"./aggregate/gte";import{LtAggregateCommand as J}from"./aggregate/lt";import{LteAggregateCommand as K}from"./aggregate/lte";import{MaxAggregateCommand as V}from"./aggregate/max";import{MinAggregateCommand as W}from"./aggregate/min";import{NeqAggregateCommand as X}from"./aggregate/neq";import{OrAggregateCommand as Y}from"./aggregate/or";import{SumAggregateCommand as Z}from"./aggregate/sum";import{AddToSetCommand as $}from"./update/addToSet";import{MaxCommand as _}from"./update/max";import{MinCommand as rr}from"./update/min";import{MulCommand as tr}from"./update/mul";import{PopCommand as or}from"./update/pop";import{PullCommand as nr}from"./update/pull";import{PullAllCommand as er}from"./update/pullAll";import{PushCommand as u}from"./update/push";import{RemoveCommand as mr}from"./update/remove";import{RenameCommand as ar}from"./update/rename";import{SetCommand as pr}from"./update/set";import{IncCommand as ir}from"./update/inc";import{QueryChain as e}from"./query/QueryChain";import{OrCommand as ur}from"./query/or";import{AndCommand as fr}from"./query/and";import{CommandUtils as p}from"./util";import{NotCommand as gr}from"./query/not";import{NorCommand as yr}from"./query/nor";import{EqCommand as dr}from"./query/eq";import{NeqCommand as Ar}from"./query/neq";import{LtCommand as cr}from"./query/lt";import{LteCommand as wr}from"./query/lte";import{GtCommand as Cr}from"./query/gt";import{GteCommand as sr}from"./query/gte";import{InCommand as lr}from"./query/in";import{NinCommand as vr}from"./query/nin";import{ExistsCommand as hr}from"./query/exists";import{ModCommand as Sr}from"./query/mod";import{AllCommand as xr}from"./query/all";import{ElemMatchCommand as Mr}from"./query/elemMatch";import{SizeCommand as qr}from"./query/size";import{Sort as Lr}from"../common/constant";var f=function(){function o(){}o.prototype.pipeline=function(){return new Q};o.prototype.avg=function(r){return new w(r)};o.prototype.count=function(){return new v};o.prototype.max=function(r){return new V(r)};o.prototype.min=function(r){return new W(r)};o.prototype.sum=function(r){return new Z(r)};o.prototype.and=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;return new A(r)};o.prototype.or=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;return new Y(r)};o.prototype.not=function(r){return new I(r)};o.prototype.cmp=function(r,t){var n=Array.isArray(r)?r:[r,t];return new C(n)};o.prototype.eq=function(r,t){var n=Array.isArray(r)?r:[r,t];return new S(n)};o.prototype.neq=function(r,t){var n=Array.isArray(r)?r:[r,t];return new X(n)};o.prototype.lt=function(r,t){var n=Array.isArray(r)?r:[r,t];return new J(n)};o.prototype.lte=function(r,t){var n=Array.isArray(r)?r:[r,t];return new K(n)};o.prototype.gt=function(r,t){var n=Array.isArray(r)?r:[r,t];return new k(n)};o.prototype.gte=function(r,t){var n=Array.isArray(r)?r:[r,t];return new H(n)};o.prototype.addToSet=function(r){return new d(r)};o.prototype.arrayElemAt=function(r,t){var n=Array.isArray(r)?r:[r,t];return new c(n)};o.prototype.indexOfArray=function(r,t,n,m){var a=Array.isArray(r)?r:[r,t,n,m].filter(function(g){return g!==void 0});return new L(a)};o.prototype.isArray=function(r){return new N(r)};o.prototype.size=function(r){return new z(r)};o.prototype.in=function(r,t){var n=Array.isArray(r)?r:[r,t];return new q(n)};o.prototype.slice=function(r,t,n){var m=Array.isArray(r)?r:[r,t,n].filter(function(a){return a!==void 0});return new G(m)};o.prototype.ifNull=function(r,t){var n=Array.isArray(r)?r:[r,t];return new M(n)};o.prototype.cond=function(r){return new l(r)};o.prototype.switch=function(r){return new B(r)};o.prototype.concat=function(r){var t=[];for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}var m=Array.isArray(r)?r:i([r],t,true);return new s(m)};o.prototype.dateToString=function(r){return new h(r)};o.prototype.toLower=function(r){return new R(r)};o.prototype.toUpper=function(r){return new D(r)};o.prototype.split=function(r,t){var n=Array.isArray(r)?r:[r,t];return new O(n)};o.prototype.substr=function(r,t,n){var m=Array.isArray(r)?r:[r,t,n];return new F(m)};o.prototype.substrBytes=function(r,t,n){var m=Array.isArray(r)?r:[r,t,n];return new U(m)};o.prototype.first=function(r){return new x(r)};o.prototype.last=function(r){return new T(r)};o.prototype.push=function(r){return new b(r)};o.prototype.let=function(r){return new E(r)};o.prototype.add=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}var n=Array.isArray(r[0])?r[0]:r;return new y(n)};o.prototype.multiply=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}var n=Array.isArray(r[0])?r[0]:r;return new P(n)};return o}();export{f as AggregateCommandFactory};var Nr=function(){function o(){this.aggregate=new f;this.Sort=Lr}o.prototype.addToSet=function(r){return new $(r)};o.prototype.inc=function(r){return new ir(r)};o.prototype.max=function(r){return new _(r)};o.prototype.min=function(r){return new rr(r)};o.prototype.mul=function(r){return new tr(r)};o.prototype.pop=function(r){return new or(r)};o.prototype.pull=function(r){return new nr(r)};o.prototype.pullAll=function(r){return new er(r)};o.prototype.push=function(r){var t=[];for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}return new(u.bind.apply(u,i([void 0,r],t,false)))};o.prototype.remove=function(){return new mr};o.prototype.rename=function(r){return new ar(r)};o.prototype.set=function(r){return new pr(r)};o.prototype.expr=function(r){return new j(r)};o.prototype.and=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;var n=new fr(r.map(p.unchain));return new e(n)};o.prototype.or=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;var n=new ur(r.map(p.unchain));return new e(n)};o.prototype.not=function(r){var t=new gr(p.unchain(r));return new e(t)};o.prototype.nor=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;var n=new yr(r.map(p.unchain));return new e(n)};o.prototype.eq=function(r){return new e(new dr(r))};o.prototype.neq=function(r){return new e(new Ar(r))};o.prototype.lt=function(r){return new e(new cr(r))};o.prototype.lte=function(r){return new e(new wr(r))};o.prototype.gt=function(r){return new e(new Cr(r))};o.prototype.gte=function(r){return new e(new sr(r))};o.prototype.in=function(r){return new e(new lr(r))};o.prototype.nin=function(r){return new e(new vr(r))};o.prototype.exists=function(r){return new e(new hr(r))};o.prototype.mod=function(r,t){return new e(new Sr(r,t))};o.prototype.all=function(r){return new e(new xr(r))};o.prototype.elemMatch=function(r){return new e(new Mr(p.unchain(r)))};o.prototype.size=function(r){return new e(new qr(r))};return o}();export{Nr as Command}; | ||
var i=function(o,r,t){if(t||arguments.length===2)for(var n=0,m=r.length,a;n<m;n++){if(a||!(n in r)){if(!a)a=Array.prototype.slice.call(r,0,n);a[n]=r[n]}}return o.concat(a||Array.prototype.slice.call(r))};import{AddAggregateCommand as y}from"./aggregate/add";import{AddToSetAggregateCommand as d}from"./aggregate/addToSet";import{AndAggregateCommand as c}from"./aggregate/and";import{ArrayElemAtAggregateCommand as A}from"./aggregate/arrayElemAt";import{AvgAggregateCommand as w}from"./aggregate/avg";import{CMPAggregateCommand as C}from"./aggregate/cmp";import{ConcatAggregateCommand as s}from"./aggregate/concat";import{CondAggregateCommand as l}from"./aggregate/cond";import{CountAggregateCommand as v}from"./aggregate/count";import{DateToStringAggregateCommand as h}from"./aggregate/dateToString";import{EqAggregateCommand as S}from"./aggregate/eq";import{FirstAggregateCommand as x}from"./aggregate/first";import{IfNullAggregateCommand as M}from"./aggregate/ifNull";import{InAggregateCommand as q}from"./aggregate/in";import{IndexOfArrayAggregateCommand as L}from"./aggregate/indexOfArray";import{IsArrayAggregateCommand as N}from"./aggregate/isArray";import{LastAggregateCommand as T}from"./aggregate/last";import{LetAggregateCommand as b}from"./aggregate/let";import{MergeObjectsAggregateCommand as E}from"./aggregate/mergeObjects";import{MultiplyAggregateCommand as P}from"./aggregate/multiply";import{NotAggregateCommand as I}from"./aggregate/not";import{PushAggregateCommand as O}from"./aggregate/push";import{SizeAggregateCommand as z}from"./aggregate/size";import{SliceAggregateCommand as G}from"./aggregate/slice";import{SplitAggregateCommand as F}from"./aggregate/split";import{SubstrAggregateCommand as U}from"./aggregate/substr";import{SubstrBytesAggregateCommand as j}from"./aggregate/substrBytes";import{SwitchAggregateCommand as B}from"./aggregate/switch";import{ToLowerAggregateCommand as R}from"./aggregate/toLower";import{ToUpperAggregateCommand as D}from"./aggregate/toUpper";import{AggregatePipeline as Q}from"./AggregatePipeline";import{ExprCommand as k}from"./query/expr";import{GtAggregateCommand as H}from"./aggregate/gt";import{GteAggregateCommand as J}from"./aggregate/gte";import{LtAggregateCommand as K}from"./aggregate/lt";import{LteAggregateCommand as V}from"./aggregate/lte";import{MaxAggregateCommand as W}from"./aggregate/max";import{MinAggregateCommand as X}from"./aggregate/min";import{NeqAggregateCommand as Y}from"./aggregate/neq";import{OrAggregateCommand as Z}from"./aggregate/or";import{SumAggregateCommand as $}from"./aggregate/sum";import{AddToSetCommand as _}from"./update/addToSet";import{MaxCommand as rr}from"./update/max";import{MinCommand as tr}from"./update/min";import{MulCommand as or}from"./update/mul";import{PopCommand as nr}from"./update/pop";import{PullCommand as er}from"./update/pull";import{PullAllCommand as mr}from"./update/pullAll";import{PushCommand as u}from"./update/push";import{RemoveCommand as ar}from"./update/remove";import{RenameCommand as pr}from"./update/rename";import{SetCommand as ir}from"./update/set";import{IncCommand as ur}from"./update/inc";import{QueryChain as e}from"./query/QueryChain";import{OrCommand as fr}from"./query/or";import{AndCommand as gr}from"./query/and";import{CommandUtils as p}from"./util";import{NotCommand as yr}from"./query/not";import{NorCommand as dr}from"./query/nor";import{EqCommand as cr}from"./query/eq";import{NeqCommand as Ar}from"./query/neq";import{LtCommand as wr}from"./query/lt";import{LteCommand as Cr}from"./query/lte";import{GtCommand as sr}from"./query/gt";import{GteCommand as lr}from"./query/gte";import{InCommand as vr}from"./query/in";import{NinCommand as hr}from"./query/nin";import{ExistsCommand as Sr}from"./query/exists";import{ModCommand as xr}from"./query/mod";import{AllCommand as Mr}from"./query/all";import{ElemMatchCommand as qr}from"./query/elemMatch";import{SizeCommand as Lr}from"./query/size";import{Sort as Nr}from"../common/constant";var f=function(){function o(){}o.prototype.pipeline=function(){return new Q};o.prototype.avg=function(r){return new w(r)};o.prototype.count=function(){return new v};o.prototype.max=function(r){return new W(r)};o.prototype.min=function(r){return new X(r)};o.prototype.sum=function(r){return new $(r)};o.prototype.and=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;return new c(r)};o.prototype.or=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;return new Z(r)};o.prototype.not=function(r){return new I(r)};o.prototype.cmp=function(r,t){var n=Array.isArray(r)?r:[r,t];return new C(n)};o.prototype.eq=function(r,t){var n=Array.isArray(r)?r:[r,t];return new S(n)};o.prototype.neq=function(r,t){var n=Array.isArray(r)?r:[r,t];return new Y(n)};o.prototype.lt=function(r,t){var n=Array.isArray(r)?r:[r,t];return new K(n)};o.prototype.lte=function(r,t){var n=Array.isArray(r)?r:[r,t];return new V(n)};o.prototype.gt=function(r,t){var n=Array.isArray(r)?r:[r,t];return new H(n)};o.prototype.gte=function(r,t){var n=Array.isArray(r)?r:[r,t];return new J(n)};o.prototype.addToSet=function(r){return new d(r)};o.prototype.arrayElemAt=function(r,t){var n=Array.isArray(r)?r:[r,t];return new A(n)};o.prototype.indexOfArray=function(r,t,n,m){var a=Array.isArray(r)?r:[r,t,n,m].filter(function(g){return g!==void 0});return new L(a)};o.prototype.isArray=function(r){return new N(r)};o.prototype.size=function(r){return new z(r)};o.prototype.in=function(r,t){var n=Array.isArray(r)?r:[r,t];return new q(n)};o.prototype.slice=function(r,t,n){var m=Array.isArray(r)?r:[r,t,n].filter(function(a){return a!==void 0});return new G(m)};o.prototype.ifNull=function(r,t){var n=Array.isArray(r)?r:[r,t];return new M(n)};o.prototype.cond=function(r){return new l(r)};o.prototype.switch=function(r){return new B(r)};o.prototype.concat=function(r){var t=[];for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}var m=Array.isArray(r)?r:i([r],t,true);return new s(m)};o.prototype.dateToString=function(r){return new h(r)};o.prototype.toLower=function(r){return new R(r)};o.prototype.toUpper=function(r){return new D(r)};o.prototype.split=function(r,t){var n=Array.isArray(r)?r:[r,t];return new F(n)};o.prototype.substr=function(r,t,n){var m=Array.isArray(r)?r:[r,t,n];return new U(m)};o.prototype.substrBytes=function(r,t,n){var m=Array.isArray(r)?r:[r,t,n];return new j(m)};o.prototype.first=function(r){return new x(r)};o.prototype.last=function(r){return new T(r)};o.prototype.push=function(r){return new O(r)};o.prototype.let=function(r){return new b(r)};o.prototype.add=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}var n=Array.isArray(r[0])?r[0]:r;return new y(n)};o.prototype.multiply=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}var n=Array.isArray(r[0])?r[0]:r;return new P(n)};o.prototype.mergeObjects=function(r){return new E(r)};return o}();export{f as AggregateCommandFactory};var Tr=function(){function o(){this.aggregate=new f;this.Sort=Nr}o.prototype.addToSet=function(r){return new _(r)};o.prototype.inc=function(r){return new ur(r)};o.prototype.max=function(r){return new rr(r)};o.prototype.min=function(r){return new tr(r)};o.prototype.mul=function(r){return new or(r)};o.prototype.pop=function(r){return new nr(r)};o.prototype.pull=function(r){return new er(r)};o.prototype.pullAll=function(r){return new mr(r)};o.prototype.push=function(r){var t=[];for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}return new(u.bind.apply(u,i([void 0,r],t,false)))};o.prototype.remove=function(){return new ar};o.prototype.rename=function(r){return new pr(r)};o.prototype.set=function(r){return new ir(r)};o.prototype.expr=function(r){return new k(r)};o.prototype.and=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;var n=new gr(r.map(p.unchain));return new e(n)};o.prototype.or=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;var n=new fr(r.map(p.unchain));return new e(n)};o.prototype.not=function(r){var t=new yr(p.unchain(r));return new e(t)};o.prototype.nor=function(){var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}r=Array.isArray(r[0])?r[0]:r;var n=new dr(r.map(p.unchain));return new e(n)};o.prototype.eq=function(r){return new e(new cr(r))};o.prototype.neq=function(r){return new e(new Ar(r))};o.prototype.lt=function(r){return new e(new wr(r))};o.prototype.lte=function(r){return new e(new Cr(r))};o.prototype.gt=function(r){return new e(new sr(r))};o.prototype.gte=function(r){return new e(new lr(r))};o.prototype.in=function(r){return new e(new vr(r))};o.prototype.nin=function(r){return new e(new hr(r))};o.prototype.exists=function(r){return new e(new Sr(r))};o.prototype.mod=function(r,t){return new e(new xr(r,t))};o.prototype.all=function(r){return new e(new Mr(r))};o.prototype.elemMatch=function(r){return new e(new qr(p.unchain(r)))};o.prototype.size=function(r){return new e(new Lr(r))};return o}();export{Tr as Command}; |
@@ -1,1 +0,1 @@ | ||
var e=function(){e=Object.assign||function(r){for(var t,i=1,s=arguments.length;i<s;i++){t=arguments[i];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[o]=t[o]}return r};return e.apply(this,arguments)};import{QueryRequest as p}from"../command/QueryRequest";import{UpdateRequest as u}from"../command/UpdateRequest";import{DocumentAction as n,Sort as a}from"../common/constant";import{ActionBuilder as c}from"../common/util";var f=function(){function r(t){this.collectionName=t;this.criteria={sort:[]}}r.prototype.limit=function(t){this.criteria.limit=t;return this};r.prototype.skip=function(t){this.criteria.skip=t;return this};r.prototype.where=function(t){this.criteria.match=t;return this};r.prototype.projection=function(t){for(var i in t){if(t[i]){if(typeof t[i]!=="object"){t[i]=1}}else{t[i]=0}}this.criteria.projection=t;return this};r.prototype.orderBy=function(t,i){this.criteria.sort.push({field:t,sort:i});return this};r.prototype.update=function(t){return this.build(n.update,e(e({},this.baseOptions()),{$update:new u(t.data).toJSON()}))};r.prototype.updateAndReturn=function(t){var i=this.findOptions();return this.build(n.findOneAndUpdate,{$match:i.$match,$update:new u(t.data).toJSON(),$options:{$sort:i.$sort,$returnDocument:"after",$upsert:false}})};r.prototype.set=function(t){return this.build(n.replace,e(e({},this.baseOptions()),{$replace:t.data}))};r.prototype.remove=function(){return this.build(n.delete,this.baseOptions())};r.prototype.get=function(){return this.build(n.queryList,e({$limit:100},this.findOptions()))};r.prototype.count=function(){return this.build(n.count,this.baseOptions())};r.prototype.baseOptions=function(){var t={};if(typeof this.criteria.match!=="undefined"){var i=new p(this.criteria.match);t.$match=i.toJSON()}if(typeof this.criteria.limit!=="undefined"){t.$limit=this.criteria.limit}return t};r.prototype.findOptions=function(){var t=this.baseOptions();if(typeof this.criteria.projection!=="undefined"){t.$project=this.criteria.projection}if(typeof this.criteria.sort!=="undefined"){t.$sort={};for(var i=0,s=this.criteria.sort;i<s.length;i++){var o=s[i];t.$sort[o.field]=o.sort===a.DESC?-1:1}}if(typeof this.criteria.skip!=="undefined"){t.$skip=this.criteria.skip}return t};r.prototype.build=function(t,i){return c.buildDocumentAction(t,this.collectionName,i)};return r}();export{f as QueryBuilder}; | ||
var e=function(){e=Object.assign||function(r){for(var t,i=1,s=arguments.length;i<s;i++){t=arguments[i];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[o]=t[o]}return r};return e.apply(this,arguments)};import{QueryRequest as p}from"../command/QueryRequest";import{UpdateRequest as u}from"../command/UpdateRequest";import{DocumentAction as n,Sort as a}from"../common/constant";import{ActionBuilder as c}from"../common/util";var f=function(){function r(t){this.collectionName=t;this.criteria={sort:[]}}r.prototype.limit=function(t){this.criteria.limit=t;return this};r.prototype.skip=function(t){this.criteria.skip=t;return this};r.prototype.where=function(t){this.criteria.match=t;return this};r.prototype.projection=function(t){for(var i in t){if(t[i]){if(typeof t[i]!=="object"){t[i]=1}}else{t[i]=0}}this.criteria.projection=t;return this};r.prototype.orderBy=function(t,i){this.criteria.sort.push({field:t,sort:i});return this};r.prototype.update=function(t){return this.build(n.update,e(e({},this.baseOptions()),{$update:new u(t.data).toJSON()}))};r.prototype.updateAndReturn=function(t){var i=this.findOptions();return this.build(n.findOneAndUpdate,{$match:i.$match,$update:new u(t.data).toJSON(),$options:{$sort:i.$sort,$returnDocument:"after",$upsert:false}})};r.prototype.set=function(t){return this.build(n.replace,e(e({},this.baseOptions()),{$replace:t.data,$upsert:true}))};r.prototype.remove=function(){return this.build(n.delete,this.baseOptions())};r.prototype.get=function(){return this.build(n.queryList,e({$limit:100},this.findOptions()))};r.prototype.count=function(){return this.build(n.count,this.baseOptions())};r.prototype.baseOptions=function(){var t={};if(typeof this.criteria.match!=="undefined"){var i=new p(this.criteria.match);t.$match=i.toJSON()}if(typeof this.criteria.limit!=="undefined"){t.$limit=this.criteria.limit}return t};r.prototype.findOptions=function(){var t=this.baseOptions();if(typeof this.criteria.projection!=="undefined"){t.$project=this.criteria.projection}if(typeof this.criteria.sort!=="undefined"){t.$sort={};for(var i=0,s=this.criteria.sort;i<s.length;i++){var o=s[i];t.$sort[o.field]=o.sort===a.DESC?-1:1}}if(typeof this.criteria.skip!=="undefined"){t.$skip=this.criteria.skip}return t};r.prototype.build=function(t,i){return c.buildDocumentAction(t,this.collectionName,i)};return r}();export{f as QueryBuilder}; |
@@ -7,5 +7,5 @@ import { RegExpParam } from '../typing'; | ||
stringify(): { | ||
$regexp: string; | ||
$regex: string; | ||
$options: string; | ||
}; | ||
} |
@@ -1,1 +0,1 @@ | ||
var e=function(){function t(o){this.regexp=o.regexp;this.options=o.options||""}t.prototype.stringify=function(){return{$regexp:this.regexp,$options:this.options}};return t}();export{e as RegExp}; | ||
var e=function(){function t(o){this.regexp=o.regexp;this.options=o.options||""}t.prototype.stringify=function(){return{$regex:this.regexp,$options:this.options}};return t}();export{e as RegExp}; |
@@ -20,2 +20,3 @@ import { CondCommandParam, DateToStringCommandParam, IndexOfArrayCommandParam, LetCommandParam, PushCommandParam, QueryChainCommand, SliceCommandParam, SwitchCommandParam } from '../typing'; | ||
import { LetAggregateCommand } from './aggregate/let'; | ||
import { MergeObjectsAggregateCommand } from './aggregate/mergeObjects'; | ||
import { MultiplyAggregateCommand } from './aggregate/multiply'; | ||
@@ -121,2 +122,3 @@ import { NotAggregateCommand } from './aggregate/not'; | ||
multiply(...val: any[]): MultiplyAggregateCommand; | ||
mergeObjects(value: string | AggregateCommand | Array<string | AggregateCommand>): MergeObjectsAggregateCommand; | ||
} | ||
@@ -123,0 +125,0 @@ export declare class Command { |
@@ -1,1 +0,1 @@ | ||
"use strict";var __spreadArray=this&&this.__spreadArray||function(t,r,e){if(e||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++){if(o||!(n in r)){if(!o)o=Array.prototype.slice.call(r,0,n);o[n]=r[n]}}return t.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:true});exports.Command=exports.AggregateCommandFactory=void 0;var add_1=require("./aggregate/add");var addToSet_1=require("./aggregate/addToSet");var and_1=require("./aggregate/and");var arrayElemAt_1=require("./aggregate/arrayElemAt");var avg_1=require("./aggregate/avg");var cmp_1=require("./aggregate/cmp");var concat_1=require("./aggregate/concat");var cond_1=require("./aggregate/cond");var count_1=require("./aggregate/count");var dateToString_1=require("./aggregate/dateToString");var eq_1=require("./aggregate/eq");var first_1=require("./aggregate/first");var ifNull_1=require("./aggregate/ifNull");var in_1=require("./aggregate/in");var indexOfArray_1=require("./aggregate/indexOfArray");var isArray_1=require("./aggregate/isArray");var last_1=require("./aggregate/last");var let_1=require("./aggregate/let");var multiply_1=require("./aggregate/multiply");var not_1=require("./aggregate/not");var push_1=require("./aggregate/push");var size_1=require("./aggregate/size");var slice_1=require("./aggregate/slice");var split_1=require("./aggregate/split");var substr_1=require("./aggregate/substr");var substrBytes_1=require("./aggregate/substrBytes");var switch_1=require("./aggregate/switch");var toLower_1=require("./aggregate/toLower");var toUpper_1=require("./aggregate/toUpper");var AggregatePipeline_1=require("./AggregatePipeline");var expr_1=require("./query/expr");var gt_1=require("./aggregate/gt");var gte_1=require("./aggregate/gte");var lt_1=require("./aggregate/lt");var lte_1=require("./aggregate/lte");var max_1=require("./aggregate/max");var min_1=require("./aggregate/min");var neq_1=require("./aggregate/neq");var or_1=require("./aggregate/or");var sum_1=require("./aggregate/sum");var addToSet_2=require("./update/addToSet");var max_2=require("./update/max");var min_2=require("./update/min");var mul_1=require("./update/mul");var pop_1=require("./update/pop");var pull_1=require("./update/pull");var pullAll_1=require("./update/pullAll");var push_2=require("./update/push");var remove_1=require("./update/remove");var rename_1=require("./update/rename");var set_1=require("./update/set");var inc_1=require("./update/inc");var QueryChain_1=require("./query/QueryChain");var or_2=require("./query/or");var and_2=require("./query/and");var util_1=require("./util");var not_2=require("./query/not");var nor_1=require("./query/nor");var eq_2=require("./query/eq");var neq_2=require("./query/neq");var lt_2=require("./query/lt");var lte_2=require("./query/lte");var gt_2=require("./query/gt");var gte_2=require("./query/gte");var in_2=require("./query/in");var nin_1=require("./query/nin");var exists_1=require("./query/exists");var mod_1=require("./query/mod");var all_1=require("./query/all");var elemMatch_1=require("./query/elemMatch");var size_2=require("./query/size");var constant_1=require("../common/constant");var AggregateCommandFactory=function(){function t(){}t.prototype.pipeline=function(){return new AggregatePipeline_1.AggregatePipeline};t.prototype.avg=function(r){return new avg_1.AvgAggregateCommand(r)};t.prototype.count=function(){return new count_1.CountAggregateCommand};t.prototype.max=function(r){return new max_1.MaxAggregateCommand(r)};t.prototype.min=function(r){return new min_1.MinAggregateCommand(r)};t.prototype.sum=function(r){return new sum_1.SumAggregateCommand(r)};t.prototype.and=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;return new and_1.AndAggregateCommand(r)};t.prototype.or=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;return new or_1.OrAggregateCommand(r)};t.prototype.not=function(r){return new not_1.NotAggregateCommand(r)};t.prototype.cmp=function(r,e){var n=Array.isArray(r)?r:[r,e];return new cmp_1.CMPAggregateCommand(n)};t.prototype.eq=function(r,e){var n=Array.isArray(r)?r:[r,e];return new eq_1.EqAggregateCommand(n)};t.prototype.neq=function(r,e){var n=Array.isArray(r)?r:[r,e];return new neq_1.NeqAggregateCommand(n)};t.prototype.lt=function(r,e){var n=Array.isArray(r)?r:[r,e];return new lt_1.LtAggregateCommand(n)};t.prototype.lte=function(r,e){var n=Array.isArray(r)?r:[r,e];return new lte_1.LteAggregateCommand(n)};t.prototype.gt=function(r,e){var n=Array.isArray(r)?r:[r,e];return new gt_1.GtAggregateCommand(n)};t.prototype.gte=function(r,e){var n=Array.isArray(r)?r:[r,e];return new gte_1.GteAggregateCommand(n)};t.prototype.addToSet=function(r){return new addToSet_1.AddToSetAggregateCommand(r)};t.prototype.arrayElemAt=function(r,e){var n=Array.isArray(r)?r:[r,e];return new arrayElemAt_1.ArrayElemAtAggregateCommand(n)};t.prototype.indexOfArray=function(r,e,n,a){var o=Array.isArray(r)?r:[r,e,n,a].filter(function(u){return u!==void 0});return new indexOfArray_1.IndexOfArrayAggregateCommand(o)};t.prototype.isArray=function(r){return new isArray_1.IsArrayAggregateCommand(r)};t.prototype.size=function(r){return new size_1.SizeAggregateCommand(r)};t.prototype.in=function(r,e){var n=Array.isArray(r)?r:[r,e];return new in_1.InAggregateCommand(n)};t.prototype.slice=function(r,e,n){var a=Array.isArray(r)?r:[r,e,n].filter(function(o){return o!==void 0});return new slice_1.SliceAggregateCommand(a)};t.prototype.ifNull=function(r,e){var n=Array.isArray(r)?r:[r,e];return new ifNull_1.IfNullAggregateCommand(n)};t.prototype.cond=function(r){return new cond_1.CondAggregateCommand(r)};t.prototype.switch=function(r){return new switch_1.SwitchAggregateCommand(r)};t.prototype.concat=function(r){var e=[];for(var n=1;n<arguments.length;n++){e[n-1]=arguments[n]}var a=Array.isArray(r)?r:__spreadArray([r],e,true);return new concat_1.ConcatAggregateCommand(a)};t.prototype.dateToString=function(r){return new dateToString_1.DateToStringAggregateCommand(r)};t.prototype.toLower=function(r){return new toLower_1.ToLowerAggregateCommand(r)};t.prototype.toUpper=function(r){return new toUpper_1.ToUpperAggregateCommand(r)};t.prototype.split=function(r,e){var n=Array.isArray(r)?r:[r,e];return new split_1.SplitAggregateCommand(n)};t.prototype.substr=function(r,e,n){var a=Array.isArray(r)?r:[r,e,n];return new substr_1.SubstrAggregateCommand(a)};t.prototype.substrBytes=function(r,e,n){var a=Array.isArray(r)?r:[r,e,n];return new substrBytes_1.SubstrBytesAggregateCommand(a)};t.prototype.first=function(r){return new first_1.FirstAggregateCommand(r)};t.prototype.last=function(r){return new last_1.LastAggregateCommand(r)};t.prototype.push=function(r){return new push_1.PushAggregateCommand(r)};t.prototype.let=function(r){return new let_1.LetAggregateCommand(r)};t.prototype.add=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}var n=Array.isArray(r[0])?r[0]:r;return new add_1.AddAggregateCommand(n)};t.prototype.multiply=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}var n=Array.isArray(r[0])?r[0]:r;return new multiply_1.MultiplyAggregateCommand(n)};return t}();exports.AggregateCommandFactory=AggregateCommandFactory;var Command=function(){function t(){this.aggregate=new AggregateCommandFactory;this.Sort=constant_1.Sort}t.prototype.addToSet=function(r){return new addToSet_2.AddToSetCommand(r)};t.prototype.inc=function(r){return new inc_1.IncCommand(r)};t.prototype.max=function(r){return new max_2.MaxCommand(r)};t.prototype.min=function(r){return new min_2.MinCommand(r)};t.prototype.mul=function(r){return new mul_1.MulCommand(r)};t.prototype.pop=function(r){return new pop_1.PopCommand(r)};t.prototype.pull=function(r){return new pull_1.PullCommand(r)};t.prototype.pullAll=function(r){return new pullAll_1.PullAllCommand(r)};t.prototype.push=function(r){var e=[];for(var n=1;n<arguments.length;n++){e[n-1]=arguments[n]}return new(push_2.PushCommand.bind.apply(push_2.PushCommand,__spreadArray([void 0,r],e,false)))};t.prototype.remove=function(){return new remove_1.RemoveCommand};t.prototype.rename=function(r){return new rename_1.RenameCommand(r)};t.prototype.set=function(r){return new set_1.SetCommand(r)};t.prototype.expr=function(r){return new expr_1.ExprCommand(r)};t.prototype.and=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;var n=new and_2.AndCommand(r.map(util_1.CommandUtils.unchain));return new QueryChain_1.QueryChain(n)};t.prototype.or=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;var n=new or_2.OrCommand(r.map(util_1.CommandUtils.unchain));return new QueryChain_1.QueryChain(n)};t.prototype.not=function(r){var e=new not_2.NotCommand(util_1.CommandUtils.unchain(r));return new QueryChain_1.QueryChain(e)};t.prototype.nor=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;var n=new nor_1.NorCommand(r.map(util_1.CommandUtils.unchain));return new QueryChain_1.QueryChain(n)};t.prototype.eq=function(r){return new QueryChain_1.QueryChain(new eq_2.EqCommand(r))};t.prototype.neq=function(r){return new QueryChain_1.QueryChain(new neq_2.NeqCommand(r))};t.prototype.lt=function(r){return new QueryChain_1.QueryChain(new lt_2.LtCommand(r))};t.prototype.lte=function(r){return new QueryChain_1.QueryChain(new lte_2.LteCommand(r))};t.prototype.gt=function(r){return new QueryChain_1.QueryChain(new gt_2.GtCommand(r))};t.prototype.gte=function(r){return new QueryChain_1.QueryChain(new gte_2.GteCommand(r))};t.prototype.in=function(r){return new QueryChain_1.QueryChain(new in_2.InCommand(r))};t.prototype.nin=function(r){return new QueryChain_1.QueryChain(new nin_1.NinCommand(r))};t.prototype.exists=function(r){return new QueryChain_1.QueryChain(new exists_1.ExistsCommand(r))};t.prototype.mod=function(r,e){return new QueryChain_1.QueryChain(new mod_1.ModCommand(r,e))};t.prototype.all=function(r){return new QueryChain_1.QueryChain(new all_1.AllCommand(r))};t.prototype.elemMatch=function(r){return new QueryChain_1.QueryChain(new elemMatch_1.ElemMatchCommand(util_1.CommandUtils.unchain(r)))};t.prototype.size=function(r){return new QueryChain_1.QueryChain(new size_2.SizeCommand(r))};return t}();exports.Command=Command; | ||
"use strict";var __spreadArray=this&&this.__spreadArray||function(t,r,e){if(e||arguments.length===2)for(var n=0,a=r.length,o;n<a;n++){if(o||!(n in r)){if(!o)o=Array.prototype.slice.call(r,0,n);o[n]=r[n]}}return t.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(exports,"__esModule",{value:true});exports.Command=exports.AggregateCommandFactory=void 0;var add_1=require("./aggregate/add");var addToSet_1=require("./aggregate/addToSet");var and_1=require("./aggregate/and");var arrayElemAt_1=require("./aggregate/arrayElemAt");var avg_1=require("./aggregate/avg");var cmp_1=require("./aggregate/cmp");var concat_1=require("./aggregate/concat");var cond_1=require("./aggregate/cond");var count_1=require("./aggregate/count");var dateToString_1=require("./aggregate/dateToString");var eq_1=require("./aggregate/eq");var first_1=require("./aggregate/first");var ifNull_1=require("./aggregate/ifNull");var in_1=require("./aggregate/in");var indexOfArray_1=require("./aggregate/indexOfArray");var isArray_1=require("./aggregate/isArray");var last_1=require("./aggregate/last");var let_1=require("./aggregate/let");var mergeObjects_1=require("./aggregate/mergeObjects");var multiply_1=require("./aggregate/multiply");var not_1=require("./aggregate/not");var push_1=require("./aggregate/push");var size_1=require("./aggregate/size");var slice_1=require("./aggregate/slice");var split_1=require("./aggregate/split");var substr_1=require("./aggregate/substr");var substrBytes_1=require("./aggregate/substrBytes");var switch_1=require("./aggregate/switch");var toLower_1=require("./aggregate/toLower");var toUpper_1=require("./aggregate/toUpper");var AggregatePipeline_1=require("./AggregatePipeline");var expr_1=require("./query/expr");var gt_1=require("./aggregate/gt");var gte_1=require("./aggregate/gte");var lt_1=require("./aggregate/lt");var lte_1=require("./aggregate/lte");var max_1=require("./aggregate/max");var min_1=require("./aggregate/min");var neq_1=require("./aggregate/neq");var or_1=require("./aggregate/or");var sum_1=require("./aggregate/sum");var addToSet_2=require("./update/addToSet");var max_2=require("./update/max");var min_2=require("./update/min");var mul_1=require("./update/mul");var pop_1=require("./update/pop");var pull_1=require("./update/pull");var pullAll_1=require("./update/pullAll");var push_2=require("./update/push");var remove_1=require("./update/remove");var rename_1=require("./update/rename");var set_1=require("./update/set");var inc_1=require("./update/inc");var QueryChain_1=require("./query/QueryChain");var or_2=require("./query/or");var and_2=require("./query/and");var util_1=require("./util");var not_2=require("./query/not");var nor_1=require("./query/nor");var eq_2=require("./query/eq");var neq_2=require("./query/neq");var lt_2=require("./query/lt");var lte_2=require("./query/lte");var gt_2=require("./query/gt");var gte_2=require("./query/gte");var in_2=require("./query/in");var nin_1=require("./query/nin");var exists_1=require("./query/exists");var mod_1=require("./query/mod");var all_1=require("./query/all");var elemMatch_1=require("./query/elemMatch");var size_2=require("./query/size");var constant_1=require("../common/constant");var AggregateCommandFactory=function(){function t(){}t.prototype.pipeline=function(){return new AggregatePipeline_1.AggregatePipeline};t.prototype.avg=function(r){return new avg_1.AvgAggregateCommand(r)};t.prototype.count=function(){return new count_1.CountAggregateCommand};t.prototype.max=function(r){return new max_1.MaxAggregateCommand(r)};t.prototype.min=function(r){return new min_1.MinAggregateCommand(r)};t.prototype.sum=function(r){return new sum_1.SumAggregateCommand(r)};t.prototype.and=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;return new and_1.AndAggregateCommand(r)};t.prototype.or=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;return new or_1.OrAggregateCommand(r)};t.prototype.not=function(r){return new not_1.NotAggregateCommand(r)};t.prototype.cmp=function(r,e){var n=Array.isArray(r)?r:[r,e];return new cmp_1.CMPAggregateCommand(n)};t.prototype.eq=function(r,e){var n=Array.isArray(r)?r:[r,e];return new eq_1.EqAggregateCommand(n)};t.prototype.neq=function(r,e){var n=Array.isArray(r)?r:[r,e];return new neq_1.NeqAggregateCommand(n)};t.prototype.lt=function(r,e){var n=Array.isArray(r)?r:[r,e];return new lt_1.LtAggregateCommand(n)};t.prototype.lte=function(r,e){var n=Array.isArray(r)?r:[r,e];return new lte_1.LteAggregateCommand(n)};t.prototype.gt=function(r,e){var n=Array.isArray(r)?r:[r,e];return new gt_1.GtAggregateCommand(n)};t.prototype.gte=function(r,e){var n=Array.isArray(r)?r:[r,e];return new gte_1.GteAggregateCommand(n)};t.prototype.addToSet=function(r){return new addToSet_1.AddToSetAggregateCommand(r)};t.prototype.arrayElemAt=function(r,e){var n=Array.isArray(r)?r:[r,e];return new arrayElemAt_1.ArrayElemAtAggregateCommand(n)};t.prototype.indexOfArray=function(r,e,n,a){var o=Array.isArray(r)?r:[r,e,n,a].filter(function(u){return u!==void 0});return new indexOfArray_1.IndexOfArrayAggregateCommand(o)};t.prototype.isArray=function(r){return new isArray_1.IsArrayAggregateCommand(r)};t.prototype.size=function(r){return new size_1.SizeAggregateCommand(r)};t.prototype.in=function(r,e){var n=Array.isArray(r)?r:[r,e];return new in_1.InAggregateCommand(n)};t.prototype.slice=function(r,e,n){var a=Array.isArray(r)?r:[r,e,n].filter(function(o){return o!==void 0});return new slice_1.SliceAggregateCommand(a)};t.prototype.ifNull=function(r,e){var n=Array.isArray(r)?r:[r,e];return new ifNull_1.IfNullAggregateCommand(n)};t.prototype.cond=function(r){return new cond_1.CondAggregateCommand(r)};t.prototype.switch=function(r){return new switch_1.SwitchAggregateCommand(r)};t.prototype.concat=function(r){var e=[];for(var n=1;n<arguments.length;n++){e[n-1]=arguments[n]}var a=Array.isArray(r)?r:__spreadArray([r],e,true);return new concat_1.ConcatAggregateCommand(a)};t.prototype.dateToString=function(r){return new dateToString_1.DateToStringAggregateCommand(r)};t.prototype.toLower=function(r){return new toLower_1.ToLowerAggregateCommand(r)};t.prototype.toUpper=function(r){return new toUpper_1.ToUpperAggregateCommand(r)};t.prototype.split=function(r,e){var n=Array.isArray(r)?r:[r,e];return new split_1.SplitAggregateCommand(n)};t.prototype.substr=function(r,e,n){var a=Array.isArray(r)?r:[r,e,n];return new substr_1.SubstrAggregateCommand(a)};t.prototype.substrBytes=function(r,e,n){var a=Array.isArray(r)?r:[r,e,n];return new substrBytes_1.SubstrBytesAggregateCommand(a)};t.prototype.first=function(r){return new first_1.FirstAggregateCommand(r)};t.prototype.last=function(r){return new last_1.LastAggregateCommand(r)};t.prototype.push=function(r){return new push_1.PushAggregateCommand(r)};t.prototype.let=function(r){return new let_1.LetAggregateCommand(r)};t.prototype.add=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}var n=Array.isArray(r[0])?r[0]:r;return new add_1.AddAggregateCommand(n)};t.prototype.multiply=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}var n=Array.isArray(r[0])?r[0]:r;return new multiply_1.MultiplyAggregateCommand(n)};t.prototype.mergeObjects=function(r){return new mergeObjects_1.MergeObjectsAggregateCommand(r)};return t}();exports.AggregateCommandFactory=AggregateCommandFactory;var Command=function(){function t(){this.aggregate=new AggregateCommandFactory;this.Sort=constant_1.Sort}t.prototype.addToSet=function(r){return new addToSet_2.AddToSetCommand(r)};t.prototype.inc=function(r){return new inc_1.IncCommand(r)};t.prototype.max=function(r){return new max_2.MaxCommand(r)};t.prototype.min=function(r){return new min_2.MinCommand(r)};t.prototype.mul=function(r){return new mul_1.MulCommand(r)};t.prototype.pop=function(r){return new pop_1.PopCommand(r)};t.prototype.pull=function(r){return new pull_1.PullCommand(r)};t.prototype.pullAll=function(r){return new pullAll_1.PullAllCommand(r)};t.prototype.push=function(r){var e=[];for(var n=1;n<arguments.length;n++){e[n-1]=arguments[n]}return new(push_2.PushCommand.bind.apply(push_2.PushCommand,__spreadArray([void 0,r],e,false)))};t.prototype.remove=function(){return new remove_1.RemoveCommand};t.prototype.rename=function(r){return new rename_1.RenameCommand(r)};t.prototype.set=function(r){return new set_1.SetCommand(r)};t.prototype.expr=function(r){return new expr_1.ExprCommand(r)};t.prototype.and=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;var n=new and_2.AndCommand(r.map(util_1.CommandUtils.unchain));return new QueryChain_1.QueryChain(n)};t.prototype.or=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;var n=new or_2.OrCommand(r.map(util_1.CommandUtils.unchain));return new QueryChain_1.QueryChain(n)};t.prototype.not=function(r){var e=new not_2.NotCommand(util_1.CommandUtils.unchain(r));return new QueryChain_1.QueryChain(e)};t.prototype.nor=function(){var r=[];for(var e=0;e<arguments.length;e++){r[e]=arguments[e]}r=Array.isArray(r[0])?r[0]:r;var n=new nor_1.NorCommand(r.map(util_1.CommandUtils.unchain));return new QueryChain_1.QueryChain(n)};t.prototype.eq=function(r){return new QueryChain_1.QueryChain(new eq_2.EqCommand(r))};t.prototype.neq=function(r){return new QueryChain_1.QueryChain(new neq_2.NeqCommand(r))};t.prototype.lt=function(r){return new QueryChain_1.QueryChain(new lt_2.LtCommand(r))};t.prototype.lte=function(r){return new QueryChain_1.QueryChain(new lte_2.LteCommand(r))};t.prototype.gt=function(r){return new QueryChain_1.QueryChain(new gt_2.GtCommand(r))};t.prototype.gte=function(r){return new QueryChain_1.QueryChain(new gte_2.GteCommand(r))};t.prototype.in=function(r){return new QueryChain_1.QueryChain(new in_2.InCommand(r))};t.prototype.nin=function(r){return new QueryChain_1.QueryChain(new nin_1.NinCommand(r))};t.prototype.exists=function(r){return new QueryChain_1.QueryChain(new exists_1.ExistsCommand(r))};t.prototype.mod=function(r,e){return new QueryChain_1.QueryChain(new mod_1.ModCommand(r,e))};t.prototype.all=function(r){return new QueryChain_1.QueryChain(new all_1.AllCommand(r))};t.prototype.elemMatch=function(r){return new QueryChain_1.QueryChain(new elemMatch_1.ElemMatchCommand(util_1.CommandUtils.unchain(r)))};t.prototype.size=function(r){return new QueryChain_1.QueryChain(new size_2.SizeCommand(r))};return t}();exports.Command=Command; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(i){for(var t,e=1,o=arguments.length;e<o;e++){t=arguments[e];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))i[r]=t[r]}return i};return __assign.apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:true});exports.QueryBuilder=void 0;var QueryRequest_1=require("../command/QueryRequest");var UpdateRequest_1=require("../command/UpdateRequest");var constant_1=require("../common/constant");var util_1=require("../common/util");var QueryBuilder=function(){function i(t){this.collectionName=t;this.criteria={sort:[]}}i.prototype.limit=function(t){this.criteria.limit=t;return this};i.prototype.skip=function(t){this.criteria.skip=t;return this};i.prototype.where=function(t){this.criteria.match=t;return this};i.prototype.projection=function(t){for(var e in t){if(t[e]){if(typeof t[e]!=="object"){t[e]=1}}else{t[e]=0}}this.criteria.projection=t;return this};i.prototype.orderBy=function(t,e){this.criteria.sort.push({field:t,sort:e});return this};i.prototype.update=function(t){return this.build(constant_1.DocumentAction.update,__assign(__assign({},this.baseOptions()),{$update:new UpdateRequest_1.UpdateRequest(t.data).toJSON()}))};i.prototype.updateAndReturn=function(t){var e=this.findOptions();return this.build(constant_1.DocumentAction.findOneAndUpdate,{$match:e.$match,$update:new UpdateRequest_1.UpdateRequest(t.data).toJSON(),$options:{$sort:e.$sort,$returnDocument:"after",$upsert:false}})};i.prototype.set=function(t){return this.build(constant_1.DocumentAction.replace,__assign(__assign({},this.baseOptions()),{$replace:t.data}))};i.prototype.remove=function(){return this.build(constant_1.DocumentAction.delete,this.baseOptions())};i.prototype.get=function(){return this.build(constant_1.DocumentAction.queryList,__assign({$limit:100},this.findOptions()))};i.prototype.count=function(){return this.build(constant_1.DocumentAction.count,this.baseOptions())};i.prototype.baseOptions=function(){var t={};if(typeof this.criteria.match!=="undefined"){var e=new QueryRequest_1.QueryRequest(this.criteria.match);t.$match=e.toJSON()}if(typeof this.criteria.limit!=="undefined"){t.$limit=this.criteria.limit}return t};i.prototype.findOptions=function(){var t=this.baseOptions();if(typeof this.criteria.projection!=="undefined"){t.$project=this.criteria.projection}if(typeof this.criteria.sort!=="undefined"){t.$sort={};for(var e=0,o=this.criteria.sort;e<o.length;e++){var r=o[e];t.$sort[r.field]=r.sort===constant_1.Sort.DESC?-1:1}}if(typeof this.criteria.skip!=="undefined"){t.$skip=this.criteria.skip}return t};i.prototype.build=function(t,e){return util_1.ActionBuilder.buildDocumentAction(t,this.collectionName,e)};return i}();exports.QueryBuilder=QueryBuilder; | ||
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(i){for(var t,e=1,o=arguments.length;e<o;e++){t=arguments[e];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))i[r]=t[r]}return i};return __assign.apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:true});exports.QueryBuilder=void 0;var QueryRequest_1=require("../command/QueryRequest");var UpdateRequest_1=require("../command/UpdateRequest");var constant_1=require("../common/constant");var util_1=require("../common/util");var QueryBuilder=function(){function i(t){this.collectionName=t;this.criteria={sort:[]}}i.prototype.limit=function(t){this.criteria.limit=t;return this};i.prototype.skip=function(t){this.criteria.skip=t;return this};i.prototype.where=function(t){this.criteria.match=t;return this};i.prototype.projection=function(t){for(var e in t){if(t[e]){if(typeof t[e]!=="object"){t[e]=1}}else{t[e]=0}}this.criteria.projection=t;return this};i.prototype.orderBy=function(t,e){this.criteria.sort.push({field:t,sort:e});return this};i.prototype.update=function(t){return this.build(constant_1.DocumentAction.update,__assign(__assign({},this.baseOptions()),{$update:new UpdateRequest_1.UpdateRequest(t.data).toJSON()}))};i.prototype.updateAndReturn=function(t){var e=this.findOptions();return this.build(constant_1.DocumentAction.findOneAndUpdate,{$match:e.$match,$update:new UpdateRequest_1.UpdateRequest(t.data).toJSON(),$options:{$sort:e.$sort,$returnDocument:"after",$upsert:false}})};i.prototype.set=function(t){return this.build(constant_1.DocumentAction.replace,__assign(__assign({},this.baseOptions()),{$replace:t.data,$upsert:true}))};i.prototype.remove=function(){return this.build(constant_1.DocumentAction.delete,this.baseOptions())};i.prototype.get=function(){return this.build(constant_1.DocumentAction.queryList,__assign({$limit:100},this.findOptions()))};i.prototype.count=function(){return this.build(constant_1.DocumentAction.count,this.baseOptions())};i.prototype.baseOptions=function(){var t={};if(typeof this.criteria.match!=="undefined"){var e=new QueryRequest_1.QueryRequest(this.criteria.match);t.$match=e.toJSON()}if(typeof this.criteria.limit!=="undefined"){t.$limit=this.criteria.limit}return t};i.prototype.findOptions=function(){var t=this.baseOptions();if(typeof this.criteria.projection!=="undefined"){t.$project=this.criteria.projection}if(typeof this.criteria.sort!=="undefined"){t.$sort={};for(var e=0,o=this.criteria.sort;e<o.length;e++){var r=o[e];t.$sort[r.field]=r.sort===constant_1.Sort.DESC?-1:1}}if(typeof this.criteria.skip!=="undefined"){t.$skip=this.criteria.skip}return t};i.prototype.build=function(t,e){return util_1.ActionBuilder.buildDocumentAction(t,this.collectionName,e)};return i}();exports.QueryBuilder=QueryBuilder; |
@@ -7,5 +7,5 @@ import { RegExpParam } from '../typing'; | ||
stringify(): { | ||
$regexp: string; | ||
$regex: string; | ||
$options: string; | ||
}; | ||
} |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.RegExp=void 0;var RegExp=function(){function e(t){this.regexp=t.regexp;this.options=t.options||""}e.prototype.stringify=function(){return{$regexp:this.regexp,$options:this.options}};return e}();exports.RegExp=RegExp; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.RegExp=void 0;var RegExp=function(){function e(t){this.regexp=t.regexp;this.options=t.options||""}e.prototype.stringify=function(){return{$regex:this.regexp,$options:this.options}};return e}();exports.RegExp=RegExp; |
{ | ||
"name": "@alipay/faas-db-builder", | ||
"version": "1.1.16-alpha.2", | ||
"version": "1.1.16-alpha.3", | ||
"description": "db builder", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
257984
358
1796
85