Socket
Socket
Sign inDemoInstall

@alipay/faas-db-builder

Package Overview
Dependencies
Maintainers
3
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/faas-db-builder - npm Package Compare versions

Comparing version 1.1.15 to 1.1.16-alpha.0

9

esm/command/AggregatePipeline.d.ts
import { Sort } from '../common/constant';
import type { QueryChainCommand, SampleAggregateParam } from '../typing';
import { LookupAggregateParam } from '../typing';
import { AggregateCommand } from './AbstractCommand';
import type { LookupAggregateParam, QueryChainCommand, ReplaceRootParam, SampleAggregateParam, UnwindParam } from '../typing';
import type { AggregateCommand } from './AbstractCommand';
export declare class AggregatePipeline {
private readonly pipeline;
constructor();
addField(fields: Record<string, string | AggregateCommand>): this;
count(field: string): this;
match(match: QueryChainCommand): this;
group(group: object): this;
project(project: Record<string, boolean | 0 | 1 | object | AggregateCommand>): this;
replaceRoot(root: ReplaceRootParam): this;
sample(sample: SampleAggregateParam): this;

@@ -16,2 +18,3 @@ lookup(lookup: LookupAggregateParam): this;

skip(skip: number): this;
unwind(unwind: string | UnwindParam): this;
done(): ({

@@ -18,0 +21,0 @@ $match: any;

@@ -1,1 +0,1 @@

import{PipelineStageName as e,Sort as u}from"../common/constant";import{DbBuildError as c}from"../common/error";import{AggregateRequest as h}from"./AggregateRequest";import{QueryRequest as m}from"./QueryRequest";var f=function(){function r(){this.pipeline=[]}r.prototype.match=function(t){this.pushStage(e.match,t);return this};r.prototype.group=function(t){this.pushStage(e.group,t);return this};r.prototype.project=function(t){this.pushStage(e.project,t);return this};r.prototype.sample=function(t){this.pushStage(e.sample,t);return this};r.prototype.lookup=function(t){this.pushStage(e.lookup,t);return this};r.prototype.sort=function(t){this.pushStage(e.sort,t);return this};r.prototype.limit=function(t){this.pushStage(e.limit,t);return this};r.prototype.skip=function(t){this.pushStage(e.skip,t);return this};r.prototype.done=function(){return this.pipeline.map(function(t){var o,i;switch(t.name){case e.match:return{$match:new m(t.param).toJSON()};case e.sample:case e.lookup:case e.limit:case e.skip:return o={},o[t.name]=t.param,o;case e.group:case e.project:return i={},i[t.name]=new h(t.param).toJSON(),i;case e.sort:return{$sort:Object.keys(t.param).reduce(function(a,n){var p;switch(t.param[n]){case u.DESC:p=-1;break;case u.ASC:p=1;break;case 1:p=1;break;case-1:p=-1;break;default:p=1}a[n]=p;return a},{})};default:{var s=t.name;throw c.invalidParam(s,"\u4E0D\u652F\u6301\u7684 aggregate \u64CD\u4F5C")}}})};r.prototype.pushStage=function(t,o){this.pipeline.push({name:t,param:o})};return r}();export{f as AggregatePipeline};
import{PipelineStageName as e,Sort as u}from"../common/constant";import{DbBuildError as c}from"../common/error";import{AggregateRequest as h}from"./AggregateRequest";import{QueryRequest as m}from"./QueryRequest";var l=function(){function r(){this.pipeline=[]}r.prototype.addField=function(t){this.pushStage(e.addFields,t);return this};r.prototype.count=function(t){this.pushStage(e.count,t);return this};r.prototype.match=function(t){this.pushStage(e.match,t);return this};r.prototype.group=function(t){this.pushStage(e.group,t);return this};r.prototype.project=function(t){this.pushStage(e.project,t);return this};r.prototype.replaceRoot=function(t){this.pushStage(e.replaceRoot,t);return this};r.prototype.sample=function(t){this.pushStage(e.sample,t);return this};r.prototype.lookup=function(t){this.pushStage(e.lookup,t);return this};r.prototype.sort=function(t){this.pushStage(e.sort,t);return this};r.prototype.limit=function(t){this.pushStage(e.limit,t);return this};r.prototype.skip=function(t){this.pushStage(e.skip,t);return this};r.prototype.unwind=function(t){this.pushStage(e.unwind,t);return this};r.prototype.done=function(){return this.pipeline.map(function(t){var i,p;switch(t.name){case e.match:return{$match:new m(t.param).toJSON()};case e.count:case e.sample:case e.lookup:case e.limit:case e.skip:case e.unwind:return i={},i[t.name]=t.param,i;case e.addFields:case e.group:case e.project:case e.replaceRoot:return p={},p[t.name]=new h(t.param).toJSON(),p;case e.sort:return{$sort:Object.keys(t.param).reduce(function(n,a){var o;switch(t.param[a]){case u.DESC:o=-1;break;case u.ASC:o=1;break;case 1:o=1;break;case-1:o=-1;break;default:o=1}n[a]=o;return n},{})};default:{var s=t.name;throw c.invalidParam(s,"\u4E0D\u652F\u6301\u7684 aggregate \u64CD\u4F5C")}}})};r.prototype.pushStage=function(t,i){this.pipeline.push({name:t,param:i})};return r}();export{l as AggregatePipeline};

@@ -28,5 +28,8 @@ export declare enum Sort {

export declare enum PipelineStageName {
addFields = "$addFields",
count = "$count",
match = "$match",
group = "$group",
project = "$project",
replaceRoot = "$replaceRoot",
sample = "$sample",

@@ -36,3 +39,4 @@ lookup = "$lookup",

limit = "$limit",
skip = "$skip"
skip = "$skip",
unwind = "$unwind"
}

@@ -1,1 +0,1 @@

export var Sort;(function(r){r["DESC"]="desc";r["ASC"]="asc"})(Sort||(Sort={}));export var CollectionAction;(function(r){r["update"]="update";r["delete"]="delete";r["query"]="query";r["queryList"]="queryList";r["create"]="create"})(CollectionAction||(CollectionAction={}));export var DocumentAction;(function(r){r["update"]="update";r["replace"]="replace";r["delete"]="delete";r["query"]="query";r["queryList"]="queryList";r["create"]="create";r["batchCreate"]="batchCreate";r["count"]="count";r["aggregate"]="aggregate"})(DocumentAction||(DocumentAction={}));export var Target;(function(r){r["collection"]="collection";r["document"]="document"})(Target||(Target={}));export var PipelineStageName;(function(r){r["match"]="$match";r["group"]="$group";r["project"]="$project";r["sample"]="$sample";r["lookup"]="$lookup";r["sort"]="$sort";r["limit"]="$limit";r["skip"]="$skip"})(PipelineStageName||(PipelineStageName={}));
export var Sort;(function(r){r["DESC"]="desc";r["ASC"]="asc"})(Sort||(Sort={}));export var CollectionAction;(function(r){r["update"]="update";r["delete"]="delete";r["query"]="query";r["queryList"]="queryList";r["create"]="create"})(CollectionAction||(CollectionAction={}));export var DocumentAction;(function(r){r["update"]="update";r["replace"]="replace";r["delete"]="delete";r["query"]="query";r["queryList"]="queryList";r["create"]="create";r["batchCreate"]="batchCreate";r["count"]="count";r["aggregate"]="aggregate"})(DocumentAction||(DocumentAction={}));export var Target;(function(r){r["collection"]="collection";r["document"]="document"})(Target||(Target={}));export var PipelineStageName;(function(r){r["addFields"]="$addFields";r["count"]="$count";r["match"]="$match";r["group"]="$group";r["project"]="$project";r["replaceRoot"]="$replaceRoot";r["sample"]="$sample";r["lookup"]="$lookup";r["sort"]="$sort";r["limit"]="$limit";r["skip"]="$skip";r["unwind"]="$unwind"})(PipelineStageName||(PipelineStageName={}));

@@ -104,1 +104,9 @@ import { AggregateCommand, QueryCommand } from './command/AbstractCommand';

}
export interface ReplaceRootParam {
newRoot: string | Record<string, string | AggregateCommand>;
}
export interface UnwindParam {
path: string;
includeArrayIndex?: string;
preserveNullAndEmptyArrays?: boolean;
}
import { Sort } from '../common/constant';
import type { QueryChainCommand, SampleAggregateParam } from '../typing';
import { LookupAggregateParam } from '../typing';
import { AggregateCommand } from './AbstractCommand';
import type { LookupAggregateParam, QueryChainCommand, ReplaceRootParam, SampleAggregateParam, UnwindParam } from '../typing';
import type { AggregateCommand } from './AbstractCommand';
export declare class AggregatePipeline {
private readonly pipeline;
constructor();
addField(fields: Record<string, string | AggregateCommand>): this;
count(field: string): this;
match(match: QueryChainCommand): this;
group(group: object): this;
project(project: Record<string, boolean | 0 | 1 | object | AggregateCommand>): this;
replaceRoot(root: ReplaceRootParam): this;
sample(sample: SampleAggregateParam): this;

@@ -16,2 +18,3 @@ lookup(lookup: LookupAggregateParam): this;

skip(skip: number): this;
unwind(unwind: string | UnwindParam): this;
done(): ({

@@ -18,0 +21,0 @@ $match: any;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AggregatePipeline=void 0;var constant_1=require("../common/constant");var error_1=require("../common/error");var AggregateRequest_1=require("./AggregateRequest");var QueryRequest_1=require("./QueryRequest");var AggregatePipeline=function(){function t(){this.pipeline=[]}t.prototype.match=function(e){this.pushStage(constant_1.PipelineStageName.match,e);return this};t.prototype.group=function(e){this.pushStage(constant_1.PipelineStageName.group,e);return this};t.prototype.project=function(e){this.pushStage(constant_1.PipelineStageName.project,e);return this};t.prototype.sample=function(e){this.pushStage(constant_1.PipelineStageName.sample,e);return this};t.prototype.lookup=function(e){this.pushStage(constant_1.PipelineStageName.lookup,e);return this};t.prototype.sort=function(e){this.pushStage(constant_1.PipelineStageName.sort,e);return this};t.prototype.limit=function(e){this.pushStage(constant_1.PipelineStageName.limit,e);return this};t.prototype.skip=function(e){this.pushStage(constant_1.PipelineStageName.skip,e);return this};t.prototype.done=function(){return this.pipeline.map(function(e){var a,i;switch(e.name){case constant_1.PipelineStageName.match:return{$match:new QueryRequest_1.QueryRequest(e.param).toJSON()};case constant_1.PipelineStageName.sample:case constant_1.PipelineStageName.lookup:case constant_1.PipelineStageName.limit:case constant_1.PipelineStageName.skip:return a={},a[e.name]=e.param,a;case constant_1.PipelineStageName.group:case constant_1.PipelineStageName.project:return i={},i[e.name]=new AggregateRequest_1.AggregateRequest(e.param).toJSON(),i;case constant_1.PipelineStageName.sort:return{$sort:Object.keys(e.param).reduce(function(n,p){var r;switch(e.param[p]){case constant_1.Sort.DESC:r=-1;break;case constant_1.Sort.ASC:r=1;break;case 1:r=1;break;case-1:r=-1;break;default:r=1}n[p]=r;return n},{})};default:{var o=e.name;throw error_1.DbBuildError.invalidParam(o,"\u4E0D\u652F\u6301\u7684 aggregate \u64CD\u4F5C")}}})};t.prototype.pushStage=function(e,a){this.pipeline.push({name:e,param:a})};return t}();exports.AggregatePipeline=AggregatePipeline;
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AggregatePipeline=void 0;var constant_1=require("../common/constant");var error_1=require("../common/error");var AggregateRequest_1=require("./AggregateRequest");var QueryRequest_1=require("./QueryRequest");var AggregatePipeline=function(){function t(){this.pipeline=[]}t.prototype.addField=function(e){this.pushStage(constant_1.PipelineStageName.addFields,e);return this};t.prototype.count=function(e){this.pushStage(constant_1.PipelineStageName.count,e);return this};t.prototype.match=function(e){this.pushStage(constant_1.PipelineStageName.match,e);return this};t.prototype.group=function(e){this.pushStage(constant_1.PipelineStageName.group,e);return this};t.prototype.project=function(e){this.pushStage(constant_1.PipelineStageName.project,e);return this};t.prototype.replaceRoot=function(e){this.pushStage(constant_1.PipelineStageName.replaceRoot,e);return this};t.prototype.sample=function(e){this.pushStage(constant_1.PipelineStageName.sample,e);return this};t.prototype.lookup=function(e){this.pushStage(constant_1.PipelineStageName.lookup,e);return this};t.prototype.sort=function(e){this.pushStage(constant_1.PipelineStageName.sort,e);return this};t.prototype.limit=function(e){this.pushStage(constant_1.PipelineStageName.limit,e);return this};t.prototype.skip=function(e){this.pushStage(constant_1.PipelineStageName.skip,e);return this};t.prototype.unwind=function(e){this.pushStage(constant_1.PipelineStageName.unwind,e);return this};t.prototype.done=function(){return this.pipeline.map(function(e){var a,r;switch(e.name){case constant_1.PipelineStageName.match:return{$match:new QueryRequest_1.QueryRequest(e.param).toJSON()};case constant_1.PipelineStageName.count:case constant_1.PipelineStageName.sample:case constant_1.PipelineStageName.lookup:case constant_1.PipelineStageName.limit:case constant_1.PipelineStageName.skip:case constant_1.PipelineStageName.unwind:return a={},a[e.name]=e.param,a;case constant_1.PipelineStageName.addFields:case constant_1.PipelineStageName.group:case constant_1.PipelineStageName.project:case constant_1.PipelineStageName.replaceRoot:return r={},r[e.name]=new AggregateRequest_1.AggregateRequest(e.param).toJSON(),r;case constant_1.PipelineStageName.sort:return{$sort:Object.keys(e.param).reduce(function(n,p){var i;switch(e.param[p]){case constant_1.Sort.DESC:i=-1;break;case constant_1.Sort.ASC:i=1;break;case 1:i=1;break;case-1:i=-1;break;default:i=1}n[p]=i;return n},{})};default:{var o=e.name;throw error_1.DbBuildError.invalidParam(o,"\u4E0D\u652F\u6301\u7684 aggregate \u64CD\u4F5C")}}})};t.prototype.pushStage=function(e,a){this.pipeline.push({name:e,param:a})};return t}();exports.AggregatePipeline=AggregatePipeline;

@@ -28,5 +28,8 @@ export declare enum Sort {

export declare enum PipelineStageName {
addFields = "$addFields",
count = "$count",
match = "$match",
group = "$group",
project = "$project",
replaceRoot = "$replaceRoot",
sample = "$sample",

@@ -36,3 +39,4 @@ lookup = "$lookup",

limit = "$limit",
skip = "$skip"
skip = "$skip",
unwind = "$unwind"
}

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PipelineStageName=exports.Target=exports.DocumentAction=exports.CollectionAction=exports.Sort=void 0;var Sort;(function(e){e["DESC"]="desc";e["ASC"]="asc"})(Sort||(exports.Sort=Sort={}));var CollectionAction;(function(e){e["update"]="update";e["delete"]="delete";e["query"]="query";e["queryList"]="queryList";e["create"]="create"})(CollectionAction||(exports.CollectionAction=CollectionAction={}));var DocumentAction;(function(e){e["update"]="update";e["replace"]="replace";e["delete"]="delete";e["query"]="query";e["queryList"]="queryList";e["create"]="create";e["batchCreate"]="batchCreate";e["count"]="count";e["aggregate"]="aggregate"})(DocumentAction||(exports.DocumentAction=DocumentAction={}));var Target;(function(e){e["collection"]="collection";e["document"]="document"})(Target||(exports.Target=Target={}));var PipelineStageName;(function(e){e["match"]="$match";e["group"]="$group";e["project"]="$project";e["sample"]="$sample";e["lookup"]="$lookup";e["sort"]="$sort";e["limit"]="$limit";e["skip"]="$skip"})(PipelineStageName||(exports.PipelineStageName=PipelineStageName={}));
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PipelineStageName=exports.Target=exports.DocumentAction=exports.CollectionAction=exports.Sort=void 0;var Sort;(function(r){r["DESC"]="desc";r["ASC"]="asc"})(Sort||(exports.Sort=Sort={}));var CollectionAction;(function(r){r["update"]="update";r["delete"]="delete";r["query"]="query";r["queryList"]="queryList";r["create"]="create"})(CollectionAction||(exports.CollectionAction=CollectionAction={}));var DocumentAction;(function(r){r["update"]="update";r["replace"]="replace";r["delete"]="delete";r["query"]="query";r["queryList"]="queryList";r["create"]="create";r["batchCreate"]="batchCreate";r["count"]="count";r["aggregate"]="aggregate"})(DocumentAction||(exports.DocumentAction=DocumentAction={}));var Target;(function(r){r["collection"]="collection";r["document"]="document"})(Target||(exports.Target=Target={}));var PipelineStageName;(function(r){r["addFields"]="$addFields";r["count"]="$count";r["match"]="$match";r["group"]="$group";r["project"]="$project";r["replaceRoot"]="$replaceRoot";r["sample"]="$sample";r["lookup"]="$lookup";r["sort"]="$sort";r["limit"]="$limit";r["skip"]="$skip";r["unwind"]="$unwind"})(PipelineStageName||(exports.PipelineStageName=PipelineStageName={}));

@@ -104,1 +104,9 @@ import { AggregateCommand, QueryCommand } from './command/AbstractCommand';

}
export interface ReplaceRootParam {
newRoot: string | Record<string, string | AggregateCommand>;
}
export interface UnwindParam {
path: string;
includeArrayIndex?: string;
preserveNullAndEmptyArrays?: boolean;
}
{
"name": "@alipay/faas-db-builder",
"version": "1.1.15",
"version": "1.1.16-alpha.0",
"description": "db builder",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc