@cloudbase/js-sdk 3.6.8-beta.0 → 3.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.esm.js.map +1 -1
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/auth/dist/index.esm.js +1 -1
- package/auth/dist/index.esm.js.map +1 -1
- package/auth/dist/index.js +1 -1
- package/auth/dist/index.js.map +1 -1
- package/database/dist/commonjs/aggregate.d.ts +29 -0
- package/database/dist/commonjs/aggregate.js +156 -0
- package/database/dist/commonjs/collection.d.ts +9 -0
- package/database/dist/commonjs/collection.js +49 -0
- package/database/dist/commonjs/command.d.ts +175 -0
- package/database/dist/commonjs/command.js +299 -0
- package/database/dist/commonjs/commands/logic.d.ts +24 -0
- package/database/dist/commonjs/commands/logic.js +89 -0
- package/database/dist/commonjs/commands/query.d.ts +68 -0
- package/database/dist/commonjs/commands/query.js +160 -0
- package/database/dist/commonjs/commands/update.d.ts +29 -0
- package/database/dist/commonjs/commands/update.js +51 -0
- package/database/dist/commonjs/config/app.config.d.ts +6 -0
- package/database/dist/commonjs/config/app.config.js +7 -0
- package/database/dist/commonjs/config/error.config.d.ts +3 -0
- package/database/dist/commonjs/config/error.config.js +16 -0
- package/database/dist/commonjs/const/code.d.ts +30 -0
- package/database/dist/commonjs/const/code.js +33 -0
- package/database/dist/commonjs/constant.d.ts +51 -0
- package/database/dist/commonjs/constant.js +75 -0
- package/database/dist/commonjs/document.d.ts +11 -0
- package/database/dist/commonjs/document.js +260 -0
- package/database/dist/commonjs/geo/index.d.ts +6 -0
- package/database/dist/commonjs/geo/index.js +22 -0
- package/database/dist/commonjs/geo/interface.d.ts +24 -0
- package/database/dist/commonjs/geo/interface.js +2 -0
- package/database/dist/commonjs/geo/lineString.d.ts +19 -0
- package/database/dist/commonjs/geo/lineString.js +86 -0
- package/database/dist/commonjs/geo/multiLineString.d.ts +18 -0
- package/database/dist/commonjs/geo/multiLineString.js +95 -0
- package/database/dist/commonjs/geo/multiPoint.d.ts +18 -0
- package/database/dist/commonjs/geo/multiPoint.js +79 -0
- package/database/dist/commonjs/geo/multiPolygon.d.ts +18 -0
- package/database/dist/commonjs/geo/multiPolygon.js +122 -0
- package/database/dist/commonjs/geo/point.d.ts +19 -0
- package/database/dist/commonjs/geo/point.js +50 -0
- package/database/dist/commonjs/geo/polygon.d.ts +19 -0
- package/database/dist/commonjs/geo/polygon.js +109 -0
- package/database/dist/commonjs/helper/symbol.d.ts +14 -0
- package/database/dist/commonjs/helper/symbol.js +31 -0
- package/database/dist/commonjs/index.d.ts +40 -0
- package/database/dist/commonjs/index.js +61 -0
- package/database/dist/commonjs/lib/util.d.ts +1 -0
- package/database/dist/commonjs/lib/util.js +26 -0
- package/database/dist/commonjs/operator-map.d.ts +4 -0
- package/database/dist/commonjs/operator-map.js +24 -0
- package/database/dist/commonjs/query.d.ts +22 -0
- package/database/dist/commonjs/query.js +252 -0
- package/database/dist/commonjs/regexp/index.d.ts +14 -0
- package/database/dist/commonjs/regexp/index.js +33 -0
- package/database/dist/commonjs/serializer/common.d.ts +11 -0
- package/database/dist/commonjs/serializer/common.js +127 -0
- package/database/dist/commonjs/serializer/datatype.d.ts +7 -0
- package/database/dist/commonjs/serializer/datatype.js +132 -0
- package/database/dist/commonjs/serializer/query.d.ts +7 -0
- package/database/dist/commonjs/serializer/query.js +232 -0
- package/database/dist/commonjs/serializer/update.d.ts +15 -0
- package/database/dist/commonjs/serializer/update.js +142 -0
- package/database/dist/commonjs/serverDate/index.d.ts +13 -0
- package/database/dist/commonjs/serverDate/index.js +30 -0
- package/database/dist/commonjs/transaction/collection.d.ts +7 -0
- package/database/dist/commonjs/transaction/collection.js +49 -0
- package/database/dist/commonjs/transaction/document.d.ts +27 -0
- package/database/dist/commonjs/transaction/document.js +205 -0
- package/database/dist/commonjs/transaction/index.d.ts +30 -0
- package/database/dist/commonjs/transaction/index.js +215 -0
- package/database/dist/commonjs/transaction/query.d.ts +43 -0
- package/database/dist/commonjs/transaction/query.js +261 -0
- package/database/dist/commonjs/typings/index.d.ts +40 -0
- package/database/dist/commonjs/typings/index.js +2 -0
- package/database/dist/commonjs/typings/realtime.d.ts +219 -0
- package/database/dist/commonjs/typings/realtime.js +2 -0
- package/database/dist/commonjs/util.d.ts +9 -0
- package/database/dist/commonjs/util.js +145 -0
- package/database/dist/commonjs/utils/error.d.ts +38 -0
- package/database/dist/commonjs/utils/error.js +91 -0
- package/database/dist/commonjs/utils/msg.d.ts +0 -0
- package/database/dist/commonjs/utils/msg.js +0 -0
- package/database/dist/commonjs/utils/symbol.d.ts +8 -0
- package/database/dist/commonjs/utils/symbol.js +58 -0
- package/database/dist/commonjs/utils/type.d.ts +13 -0
- package/database/dist/commonjs/utils/type.js +34 -0
- package/database/dist/commonjs/utils/utils.d.ts +4 -0
- package/database/dist/commonjs/utils/utils.js +39 -0
- package/database/dist/commonjs/validate.d.ts +1 -0
- package/database/dist/commonjs/validate.js +60 -0
- package/database/dist/esm/aggregate.d.ts +29 -0
- package/database/dist/esm/aggregate.js +154 -0
- package/database/dist/esm/collection.d.ts +9 -0
- package/database/dist/esm/collection.js +46 -0
- package/database/dist/esm/command.d.ts +175 -0
- package/database/dist/esm/command.js +296 -0
- package/database/dist/esm/commands/logic.d.ts +24 -0
- package/database/dist/esm/commands/logic.js +84 -0
- package/database/dist/esm/commands/query.d.ts +68 -0
- package/database/dist/esm/commands/query.js +154 -0
- package/database/dist/esm/commands/update.d.ts +29 -0
- package/database/dist/esm/commands/update.js +46 -0
- package/database/dist/esm/config/app.config.d.ts +6 -0
- package/database/dist/esm/config/app.config.js +5 -0
- package/database/dist/esm/config/error.config.d.ts +3 -0
- package/database/dist/esm/config/error.config.js +13 -0
- package/database/dist/esm/const/code.d.ts +30 -0
- package/database/dist/esm/const/code.js +30 -0
- package/database/dist/esm/constant.d.ts +51 -0
- package/database/dist/esm/constant.js +65 -0
- package/database/dist/esm/document.d.ts +11 -0
- package/database/dist/esm/document.js +257 -0
- package/database/dist/esm/geo/index.d.ts +6 -0
- package/database/dist/esm/geo/index.js +6 -0
- package/database/dist/esm/geo/interface.d.ts +24 -0
- package/database/dist/esm/geo/interface.js +1 -0
- package/database/dist/esm/geo/lineString.d.ts +19 -0
- package/database/dist/esm/geo/lineString.js +83 -0
- package/database/dist/esm/geo/multiLineString.d.ts +18 -0
- package/database/dist/esm/geo/multiLineString.js +92 -0
- package/database/dist/esm/geo/multiPoint.d.ts +18 -0
- package/database/dist/esm/geo/multiPoint.js +76 -0
- package/database/dist/esm/geo/multiPolygon.d.ts +18 -0
- package/database/dist/esm/geo/multiPolygon.js +119 -0
- package/database/dist/esm/geo/point.d.ts +19 -0
- package/database/dist/esm/geo/point.js +47 -0
- package/database/dist/esm/geo/polygon.d.ts +19 -0
- package/database/dist/esm/geo/polygon.js +106 -0
- package/database/dist/esm/helper/symbol.d.ts +14 -0
- package/database/dist/esm/helper/symbol.js +14 -0
- package/database/dist/esm/index.d.ts +40 -0
- package/database/dist/esm/index.js +55 -0
- package/database/dist/esm/lib/util.d.ts +1 -0
- package/database/dist/esm/lib/util.js +22 -0
- package/database/dist/esm/operator-map.d.ts +4 -0
- package/database/dist/esm/operator-map.js +20 -0
- package/database/dist/esm/query.d.ts +22 -0
- package/database/dist/esm/query.js +249 -0
- package/database/dist/esm/regexp/index.d.ts +14 -0
- package/database/dist/esm/regexp/index.js +29 -0
- package/database/dist/esm/serializer/common.d.ts +11 -0
- package/database/dist/esm/serializer/common.js +118 -0
- package/database/dist/esm/serializer/datatype.d.ts +7 -0
- package/database/dist/esm/serializer/datatype.js +127 -0
- package/database/dist/esm/serializer/query.d.ts +7 -0
- package/database/dist/esm/serializer/query.js +229 -0
- package/database/dist/esm/serializer/update.d.ts +15 -0
- package/database/dist/esm/serializer/update.js +139 -0
- package/database/dist/esm/serverDate/index.d.ts +13 -0
- package/database/dist/esm/serverDate/index.js +26 -0
- package/database/dist/esm/transaction/collection.d.ts +7 -0
- package/database/dist/esm/transaction/collection.js +46 -0
- package/database/dist/esm/transaction/document.d.ts +27 -0
- package/database/dist/esm/transaction/document.js +202 -0
- package/database/dist/esm/transaction/index.d.ts +30 -0
- package/database/dist/esm/transaction/index.js +210 -0
- package/database/dist/esm/transaction/query.d.ts +43 -0
- package/database/dist/esm/transaction/query.js +258 -0
- package/database/dist/esm/typings/index.d.ts +40 -0
- package/database/dist/esm/typings/index.js +1 -0
- package/database/dist/esm/typings/realtime.d.ts +219 -0
- package/database/dist/esm/typings/realtime.js +1 -0
- package/database/dist/esm/util.d.ts +9 -0
- package/database/dist/esm/util.js +142 -0
- package/database/dist/esm/utils/error.d.ts +38 -0
- package/database/dist/esm/utils/error.js +84 -0
- package/database/dist/esm/utils/msg.d.ts +0 -0
- package/database/dist/esm/utils/msg.js +0 -0
- package/database/dist/esm/utils/symbol.d.ts +8 -0
- package/database/dist/esm/utils/symbol.js +55 -0
- package/database/dist/esm/utils/type.d.ts +13 -0
- package/database/dist/esm/utils/type.js +20 -0
- package/database/dist/esm/utils/utils.d.ts +4 -0
- package/database/dist/esm/utils/utils.js +33 -0
- package/database/dist/esm/validate.d.ts +1 -0
- package/database/dist/esm/validate.js +57 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/miniprogram_dist/auth/index.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/oauth/dist/index.esm.js.map +1 -1
- package/oauth/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/types/package.json +1 -1
- package/utilities/package.json +2 -2
- package/database/dist/index.d.ts +0 -3
- package/database/dist/index.esm.js +0 -2
- package/database/dist/index.esm.js.map +0 -1
- package/database/dist/index.js +0 -2
- package/database/dist/index.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default class Aggregation {
|
|
2
|
+
_db: any;
|
|
3
|
+
_request: any;
|
|
4
|
+
_stages: any[];
|
|
5
|
+
_collectionName: string;
|
|
6
|
+
constructor(db?: any, collectionName?: any);
|
|
7
|
+
end(): Promise<any>;
|
|
8
|
+
unwrap(): any[];
|
|
9
|
+
done(): {
|
|
10
|
+
[x: number]: any;
|
|
11
|
+
}[];
|
|
12
|
+
_pipe(stage: any, param: any): this;
|
|
13
|
+
addFields(param: any): this;
|
|
14
|
+
bucket(param: any): this;
|
|
15
|
+
bucketAuto(param: any): this;
|
|
16
|
+
count(param: any): this;
|
|
17
|
+
geoNear(param: any): this;
|
|
18
|
+
group(param: any): this;
|
|
19
|
+
limit(param: any): this;
|
|
20
|
+
match(param: any): this;
|
|
21
|
+
project(param: any): this;
|
|
22
|
+
lookup(param: any): this;
|
|
23
|
+
replaceRoot(param: any): this;
|
|
24
|
+
sample(param: any): this;
|
|
25
|
+
skip(param: any): this;
|
|
26
|
+
sort(param: any): this;
|
|
27
|
+
sortByCount(param: any): this;
|
|
28
|
+
unwind(param: any): this;
|
|
29
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var index_1 = require("./index");
|
|
40
|
+
var bson_1 = require("bson");
|
|
41
|
+
var query_1 = require("./serializer/query");
|
|
42
|
+
var geo_1 = require("./geo");
|
|
43
|
+
var Aggregation = (function () {
|
|
44
|
+
function Aggregation(db, collectionName) {
|
|
45
|
+
this._stages = [];
|
|
46
|
+
if (db && collectionName) {
|
|
47
|
+
this._db = db;
|
|
48
|
+
this._request = index_1.Db.createRequest(this._db.config);
|
|
49
|
+
this._collectionName = collectionName;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
Aggregation.prototype.end = function () {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var result;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
if (!this._collectionName || !this._db) {
|
|
59
|
+
throw new Error('Aggregation pipeline cannot send request');
|
|
60
|
+
}
|
|
61
|
+
return [4, this._request.send('database.aggregate', {
|
|
62
|
+
collectionName: this._collectionName,
|
|
63
|
+
stages: this._stages
|
|
64
|
+
})];
|
|
65
|
+
case 1:
|
|
66
|
+
result = _a.sent();
|
|
67
|
+
if (result && result.data && result.data.list) {
|
|
68
|
+
return [2, {
|
|
69
|
+
requestId: result.requestId,
|
|
70
|
+
data: JSON.parse(result.data.list).map(bson_1.EJSON.parse)
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
return [2, result];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
Aggregation.prototype.unwrap = function () {
|
|
79
|
+
return this._stages;
|
|
80
|
+
};
|
|
81
|
+
Aggregation.prototype.done = function () {
|
|
82
|
+
return this._stages.map(function (_a) {
|
|
83
|
+
var _b;
|
|
84
|
+
var stageKey = _a.stageKey, stageValue = _a.stageValue;
|
|
85
|
+
return _b = {},
|
|
86
|
+
_b[stageKey] = JSON.parse(stageValue),
|
|
87
|
+
_b;
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
Aggregation.prototype._pipe = function (stage, param) {
|
|
91
|
+
this._stages.push({
|
|
92
|
+
stageKey: "$".concat(stage),
|
|
93
|
+
stageValue: JSON.stringify(param)
|
|
94
|
+
});
|
|
95
|
+
return this;
|
|
96
|
+
};
|
|
97
|
+
Aggregation.prototype.addFields = function (param) {
|
|
98
|
+
return this._pipe('addFields', param);
|
|
99
|
+
};
|
|
100
|
+
Aggregation.prototype.bucket = function (param) {
|
|
101
|
+
return this._pipe('bucket', param);
|
|
102
|
+
};
|
|
103
|
+
Aggregation.prototype.bucketAuto = function (param) {
|
|
104
|
+
return this._pipe('bucketAuto', param);
|
|
105
|
+
};
|
|
106
|
+
Aggregation.prototype.count = function (param) {
|
|
107
|
+
return this._pipe('count', param);
|
|
108
|
+
};
|
|
109
|
+
Aggregation.prototype.geoNear = function (param) {
|
|
110
|
+
if (param.query) {
|
|
111
|
+
param.query = query_1.QuerySerializer.encode(param.query);
|
|
112
|
+
}
|
|
113
|
+
if (param.distanceMultiplier && typeof (param.distanceMultiplier) === 'number') {
|
|
114
|
+
param.distanceMultiplier = param.distanceMultiplier;
|
|
115
|
+
}
|
|
116
|
+
if (param.near) {
|
|
117
|
+
param.near = new geo_1.Point(param.near.longitude, param.near.latitude).toJSON();
|
|
118
|
+
}
|
|
119
|
+
return this._pipe('geoNear', param);
|
|
120
|
+
};
|
|
121
|
+
Aggregation.prototype.group = function (param) {
|
|
122
|
+
return this._pipe('group', param);
|
|
123
|
+
};
|
|
124
|
+
Aggregation.prototype.limit = function (param) {
|
|
125
|
+
return this._pipe('limit', param);
|
|
126
|
+
};
|
|
127
|
+
Aggregation.prototype.match = function (param) {
|
|
128
|
+
return this._pipe('match', query_1.QuerySerializer.encode(param));
|
|
129
|
+
};
|
|
130
|
+
Aggregation.prototype.project = function (param) {
|
|
131
|
+
return this._pipe('project', param);
|
|
132
|
+
};
|
|
133
|
+
Aggregation.prototype.lookup = function (param) {
|
|
134
|
+
return this._pipe('lookup', param);
|
|
135
|
+
};
|
|
136
|
+
Aggregation.prototype.replaceRoot = function (param) {
|
|
137
|
+
return this._pipe('replaceRoot', param);
|
|
138
|
+
};
|
|
139
|
+
Aggregation.prototype.sample = function (param) {
|
|
140
|
+
return this._pipe('sample', param);
|
|
141
|
+
};
|
|
142
|
+
Aggregation.prototype.skip = function (param) {
|
|
143
|
+
return this._pipe('skip', param);
|
|
144
|
+
};
|
|
145
|
+
Aggregation.prototype.sort = function (param) {
|
|
146
|
+
return this._pipe('sort', param);
|
|
147
|
+
};
|
|
148
|
+
Aggregation.prototype.sortByCount = function (param) {
|
|
149
|
+
return this._pipe('sortByCount', param);
|
|
150
|
+
};
|
|
151
|
+
Aggregation.prototype.unwind = function (param) {
|
|
152
|
+
return this._pipe('unwind', param);
|
|
153
|
+
};
|
|
154
|
+
return Aggregation;
|
|
155
|
+
}());
|
|
156
|
+
exports.default = Aggregation;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DocumentReference } from './document';
|
|
2
|
+
import { Query } from './query';
|
|
3
|
+
import Aggregation from './aggregate';
|
|
4
|
+
export declare class CollectionReference extends Query {
|
|
5
|
+
get name(): string;
|
|
6
|
+
doc(docID?: string | number): DocumentReference;
|
|
7
|
+
add(data: Object | Object[], callback?: any): Promise<any>;
|
|
8
|
+
aggregate(): Aggregation;
|
|
9
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CollectionReference = void 0;
|
|
19
|
+
var document_1 = require("./document");
|
|
20
|
+
var query_1 = require("./query");
|
|
21
|
+
var aggregate_1 = require("./aggregate");
|
|
22
|
+
var CollectionReference = (function (_super) {
|
|
23
|
+
__extends(CollectionReference, _super);
|
|
24
|
+
function CollectionReference(db, coll) {
|
|
25
|
+
return _super.call(this, db, coll) || this;
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(CollectionReference.prototype, "name", {
|
|
28
|
+
get: function () {
|
|
29
|
+
return this._coll;
|
|
30
|
+
},
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
CollectionReference.prototype.doc = function (docID) {
|
|
35
|
+
if (typeof docID !== 'string' && typeof docID !== 'number') {
|
|
36
|
+
throw new Error('docId必须为字符串或数字');
|
|
37
|
+
}
|
|
38
|
+
return new document_1.DocumentReference(this._db, this._coll, docID);
|
|
39
|
+
};
|
|
40
|
+
CollectionReference.prototype.add = function (data, callback) {
|
|
41
|
+
var docRef = new document_1.DocumentReference(this._db, this._coll, undefined);
|
|
42
|
+
return docRef.create(data, callback);
|
|
43
|
+
};
|
|
44
|
+
CollectionReference.prototype.aggregate = function () {
|
|
45
|
+
return new aggregate_1.default(this._db, this._coll);
|
|
46
|
+
};
|
|
47
|
+
return CollectionReference;
|
|
48
|
+
}(query_1.Query));
|
|
49
|
+
exports.CollectionReference = CollectionReference;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { QueryCommand } from './commands/query';
|
|
2
|
+
import { LogicCommand } from './commands/logic';
|
|
3
|
+
import { UpdateCommand } from './commands/update';
|
|
4
|
+
import Aggregation from './aggregate';
|
|
5
|
+
export type IQueryCondition = Record<string, any> | LogicCommand;
|
|
6
|
+
export declare const Command: {
|
|
7
|
+
eq(val: any): QueryCommand;
|
|
8
|
+
neq(val: any): QueryCommand;
|
|
9
|
+
lt(val: any): QueryCommand;
|
|
10
|
+
lte(val: any): QueryCommand;
|
|
11
|
+
gt(val: any): QueryCommand;
|
|
12
|
+
gte(val: any): QueryCommand;
|
|
13
|
+
in(val: any): QueryCommand;
|
|
14
|
+
nin(val: any): QueryCommand;
|
|
15
|
+
all(val: any): QueryCommand;
|
|
16
|
+
elemMatch(val: any): QueryCommand;
|
|
17
|
+
exists(val: boolean): QueryCommand;
|
|
18
|
+
size(val: number): QueryCommand;
|
|
19
|
+
mod(val: number[]): QueryCommand;
|
|
20
|
+
geoNear(val: any): QueryCommand;
|
|
21
|
+
geoWithin(val: any): QueryCommand;
|
|
22
|
+
geoIntersects(val: any): QueryCommand;
|
|
23
|
+
and(...__expressions__: IQueryCondition[]): LogicCommand;
|
|
24
|
+
nor(...__expressions__: IQueryCondition[]): LogicCommand;
|
|
25
|
+
or(...__expressions__: IQueryCondition[]): LogicCommand;
|
|
26
|
+
not(...__expressions__: IQueryCondition[]): LogicCommand;
|
|
27
|
+
set(val: any): UpdateCommand;
|
|
28
|
+
remove(): UpdateCommand;
|
|
29
|
+
inc(val: number): UpdateCommand;
|
|
30
|
+
mul(val: number): UpdateCommand;
|
|
31
|
+
push(...args: any[]): UpdateCommand;
|
|
32
|
+
pull(values: any): UpdateCommand;
|
|
33
|
+
pullAll(values: any): UpdateCommand;
|
|
34
|
+
pop(): UpdateCommand;
|
|
35
|
+
shift(): UpdateCommand;
|
|
36
|
+
unshift(...__values__: any[]): UpdateCommand;
|
|
37
|
+
addToSet(values: any): UpdateCommand;
|
|
38
|
+
rename(values: any): UpdateCommand;
|
|
39
|
+
bit(values: any): UpdateCommand;
|
|
40
|
+
max(values: any): UpdateCommand;
|
|
41
|
+
min(values: any): UpdateCommand;
|
|
42
|
+
expr(values: AggregationOperator): {
|
|
43
|
+
$expr: AggregationOperator;
|
|
44
|
+
};
|
|
45
|
+
jsonSchema(schema: any): {
|
|
46
|
+
$jsonSchema: any;
|
|
47
|
+
};
|
|
48
|
+
text(values: string | {
|
|
49
|
+
search: string;
|
|
50
|
+
language?: string;
|
|
51
|
+
caseSensitive?: boolean;
|
|
52
|
+
diacriticSensitive: boolean;
|
|
53
|
+
}): {
|
|
54
|
+
$search: {
|
|
55
|
+
(regexp: string | RegExp): number;
|
|
56
|
+
(searcher: {
|
|
57
|
+
[Symbol.search](string: string): number;
|
|
58
|
+
}): number;
|
|
59
|
+
};
|
|
60
|
+
$language?: undefined;
|
|
61
|
+
$caseSensitive?: undefined;
|
|
62
|
+
$diacriticSensitive?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
$search: string;
|
|
65
|
+
$language: string;
|
|
66
|
+
$caseSensitive: boolean;
|
|
67
|
+
$diacriticSensitive: boolean;
|
|
68
|
+
};
|
|
69
|
+
aggregate: {
|
|
70
|
+
pipeline(): Aggregation;
|
|
71
|
+
abs: (param: any) => AggregationOperator;
|
|
72
|
+
add: (param: any) => AggregationOperator;
|
|
73
|
+
ceil: (param: any) => AggregationOperator;
|
|
74
|
+
divide: (param: any) => AggregationOperator;
|
|
75
|
+
exp: (param: any) => AggregationOperator;
|
|
76
|
+
floor: (param: any) => AggregationOperator;
|
|
77
|
+
ln: (param: any) => AggregationOperator;
|
|
78
|
+
log: (param: any) => AggregationOperator;
|
|
79
|
+
log10: (param: any) => AggregationOperator;
|
|
80
|
+
mod: (param: any) => AggregationOperator;
|
|
81
|
+
multiply: (param: any) => AggregationOperator;
|
|
82
|
+
pow: (param: any) => AggregationOperator;
|
|
83
|
+
sqrt: (param: any) => AggregationOperator;
|
|
84
|
+
subtract: (param: any) => AggregationOperator;
|
|
85
|
+
trunc: (param: any) => AggregationOperator;
|
|
86
|
+
arrayElemAt: (param: any) => AggregationOperator;
|
|
87
|
+
arrayToObject: (param: any) => AggregationOperator;
|
|
88
|
+
concatArrays: (param: any) => AggregationOperator;
|
|
89
|
+
filter: (param: any) => AggregationOperator;
|
|
90
|
+
in: (param: any) => AggregationOperator;
|
|
91
|
+
indexOfArray: (param: any) => AggregationOperator;
|
|
92
|
+
isArray: (param: any) => AggregationOperator;
|
|
93
|
+
map: (param: any) => AggregationOperator;
|
|
94
|
+
range: (param: any) => AggregationOperator;
|
|
95
|
+
reduce: (param: any) => AggregationOperator;
|
|
96
|
+
reverseArray: (param: any) => AggregationOperator;
|
|
97
|
+
size: (param: any) => AggregationOperator;
|
|
98
|
+
slice: (param: any) => AggregationOperator;
|
|
99
|
+
zip: (param: any) => AggregationOperator;
|
|
100
|
+
and: (param: any) => AggregationOperator;
|
|
101
|
+
not: (param: any) => AggregationOperator;
|
|
102
|
+
or: (param: any) => AggregationOperator;
|
|
103
|
+
cmp: (param: any) => AggregationOperator;
|
|
104
|
+
eq: (param: any) => AggregationOperator;
|
|
105
|
+
gt: (param: any) => AggregationOperator;
|
|
106
|
+
gte: (param: any) => AggregationOperator;
|
|
107
|
+
lt: (param: any) => AggregationOperator;
|
|
108
|
+
lte: (param: any) => AggregationOperator;
|
|
109
|
+
neq: (param: any) => AggregationOperator;
|
|
110
|
+
cond: (param: any) => AggregationOperator;
|
|
111
|
+
ifNull: (param: any) => AggregationOperator;
|
|
112
|
+
switch: (param: any) => AggregationOperator;
|
|
113
|
+
dateFromParts: (param: any) => AggregationOperator;
|
|
114
|
+
dateFromString: (param: any) => AggregationOperator;
|
|
115
|
+
dayOfMonth: (param: any) => AggregationOperator;
|
|
116
|
+
dayOfWeek: (param: any) => AggregationOperator;
|
|
117
|
+
dayOfYear: (param: any) => AggregationOperator;
|
|
118
|
+
isoDayOfWeek: (param: any) => AggregationOperator;
|
|
119
|
+
isoWeek: (param: any) => AggregationOperator;
|
|
120
|
+
isoWeekYear: (param: any) => AggregationOperator;
|
|
121
|
+
millisecond: (param: any) => AggregationOperator;
|
|
122
|
+
minute: (param: any) => AggregationOperator;
|
|
123
|
+
month: (param: any) => AggregationOperator;
|
|
124
|
+
second: (param: any) => AggregationOperator;
|
|
125
|
+
hour: (param: any) => AggregationOperator;
|
|
126
|
+
week: (param: any) => AggregationOperator;
|
|
127
|
+
year: (param: any) => AggregationOperator;
|
|
128
|
+
literal: (param: any) => AggregationOperator;
|
|
129
|
+
mergeObjects: (param: any) => AggregationOperator;
|
|
130
|
+
objectToArray: (param: any) => AggregationOperator;
|
|
131
|
+
allElementsTrue: (param: any) => AggregationOperator;
|
|
132
|
+
anyElementTrue: (param: any) => AggregationOperator;
|
|
133
|
+
setDifference: (param: any) => AggregationOperator;
|
|
134
|
+
setEquals: (param: any) => AggregationOperator;
|
|
135
|
+
setIntersection: (param: any) => AggregationOperator;
|
|
136
|
+
setIsSubset: (param: any) => AggregationOperator;
|
|
137
|
+
setUnion: (param: any) => AggregationOperator;
|
|
138
|
+
concat: (param: any) => AggregationOperator;
|
|
139
|
+
dateToString: (param: any) => AggregationOperator;
|
|
140
|
+
indexOfBytes: (param: any) => AggregationOperator;
|
|
141
|
+
indexOfCP: (param: any) => AggregationOperator;
|
|
142
|
+
split: (param: any) => AggregationOperator;
|
|
143
|
+
strLenBytes: (param: any) => AggregationOperator;
|
|
144
|
+
strLenCP: (param: any) => AggregationOperator;
|
|
145
|
+
strcasecmp: (param: any) => AggregationOperator;
|
|
146
|
+
substr: (param: any) => AggregationOperator;
|
|
147
|
+
substrBytes: (param: any) => AggregationOperator;
|
|
148
|
+
substrCP: (param: any) => AggregationOperator;
|
|
149
|
+
toLower: (param: any) => AggregationOperator;
|
|
150
|
+
toUpper: (param: any) => AggregationOperator;
|
|
151
|
+
meta: (param: any) => AggregationOperator;
|
|
152
|
+
addToSet: (param: any) => AggregationOperator;
|
|
153
|
+
avg: (param: any) => AggregationOperator;
|
|
154
|
+
first: (param: any) => AggregationOperator;
|
|
155
|
+
last: (param: any) => AggregationOperator;
|
|
156
|
+
max: (param: any) => AggregationOperator;
|
|
157
|
+
min: (param: any) => AggregationOperator;
|
|
158
|
+
push: (param: any) => AggregationOperator;
|
|
159
|
+
stdDevPop: (param: any) => AggregationOperator;
|
|
160
|
+
stdDevSamp: (param: any) => AggregationOperator;
|
|
161
|
+
sum: (param: any) => AggregationOperator;
|
|
162
|
+
let: (param: any) => AggregationOperator;
|
|
163
|
+
};
|
|
164
|
+
project: {
|
|
165
|
+
slice: (param: any) => ProjectionOperator;
|
|
166
|
+
elemMatch: (param: any) => ProjectionOperator;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
declare class AggregationOperator {
|
|
170
|
+
constructor(name: any, param: any);
|
|
171
|
+
}
|
|
172
|
+
declare class ProjectionOperator {
|
|
173
|
+
constructor(name: any, param: any);
|
|
174
|
+
}
|
|
175
|
+
export default Command;
|