@cloudbase/database 1.4.3 → 1.5.0
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/dist/commonjs/ObjectId/index.d.ts +1 -1
- package/dist/commonjs/ObjectId/index.js +16 -9
- package/dist/commonjs/aggregate.js +126 -75
- package/dist/commonjs/collection.d.ts +3 -2
- package/dist/commonjs/collection.js +131 -58
- package/dist/commonjs/command.d.ts +5 -5
- package/dist/commonjs/command.js +181 -154
- package/dist/commonjs/commands/logic.js +30 -20
- package/dist/commonjs/commands/query.d.ts +1 -1
- package/dist/commonjs/commands/query.js +85 -65
- package/dist/commonjs/commands/update.js +9 -7
- package/dist/commonjs/config/error.config.js +1 -0
- package/dist/commonjs/const/code.js +1 -0
- package/dist/commonjs/constant.d.ts +7 -7
- package/dist/commonjs/constant.js +13 -11
- package/dist/commonjs/document.d.ts +10 -6
- package/dist/commonjs/document.js +305 -193
- package/dist/commonjs/geo/index.js +20 -9
- package/dist/commonjs/geo/lineString.d.ts +1 -1
- package/dist/commonjs/geo/lineString.js +62 -33
- package/dist/commonjs/geo/multiLineString.d.ts +1 -1
- package/dist/commonjs/geo/multiLineString.js +71 -32
- package/dist/commonjs/geo/multiPoint.d.ts +1 -1
- package/dist/commonjs/geo/multiPoint.js +58 -29
- package/dist/commonjs/geo/multiPolygon.d.ts +1 -1
- package/dist/commonjs/geo/multiPolygon.js +96 -36
- package/dist/commonjs/geo/point.d.ts +1 -1
- package/dist/commonjs/geo/point.js +30 -23
- package/dist/commonjs/geo/polygon.d.ts +1 -1
- package/dist/commonjs/geo/polygon.js +78 -39
- package/dist/commonjs/helper/symbol.js +17 -5
- package/dist/commonjs/index.d.ts +8 -2
- package/dist/commonjs/index.js +73 -20
- package/dist/commonjs/lib/util.d.ts +1 -0
- package/dist/commonjs/lib/util.js +26 -0
- package/dist/commonjs/operator-map.js +7 -6
- package/dist/commonjs/query.d.ts +8 -4
- package/dist/commonjs/query.js +308 -201
- package/dist/commonjs/regexp/index.d.ts +1 -1
- package/dist/commonjs/regexp/index.js +16 -9
- package/dist/commonjs/serializer/common.d.ts +2 -2
- package/dist/commonjs/serializer/common.js +59 -22
- package/dist/commonjs/serializer/datatype.d.ts +2 -2
- package/dist/commonjs/serializer/datatype.js +58 -21
- package/dist/commonjs/serializer/query.d.ts +1 -1
- package/dist/commonjs/serializer/query.js +137 -127
- package/dist/commonjs/serializer/update.d.ts +1 -1
- package/dist/commonjs/serializer/update.js +83 -78
- package/dist/commonjs/serverDate/index.d.ts +1 -1
- package/dist/commonjs/serverDate/index.js +16 -9
- package/dist/commonjs/transaction/collection.d.ts +7 -0
- package/dist/commonjs/transaction/collection.js +49 -0
- package/dist/commonjs/transaction/document.d.ts +27 -0
- package/dist/commonjs/transaction/document.js +205 -0
- package/dist/commonjs/transaction/index.js +196 -86
- package/dist/commonjs/transaction/query.d.ts +43 -0
- package/dist/commonjs/transaction/query.js +261 -0
- package/dist/commonjs/typings/index.d.ts +4 -4
- package/dist/commonjs/typings/realtime.d.ts +16 -16
- package/dist/commonjs/util.js +123 -92
- package/dist/commonjs/utils/error.d.ts +2 -1
- package/dist/commonjs/utils/error.js +74 -38
- package/dist/commonjs/utils/symbol.js +33 -14
- package/dist/commonjs/utils/type.d.ts +1 -1
- package/dist/commonjs/utils/type.js +25 -13
- package/dist/commonjs/utils/utils.d.ts +4 -1
- package/dist/commonjs/utils/utils.js +93 -22
- package/dist/commonjs/validate.js +79 -63
- package/dist/esm/ObjectId/index.d.ts +1 -1
- package/dist/esm/ObjectId/index.js +15 -8
- package/dist/esm/aggregate.js +118 -66
- package/dist/esm/collection.d.ts +3 -2
- package/dist/esm/collection.js +125 -52
- package/dist/esm/command.d.ts +5 -5
- package/dist/esm/command.js +175 -147
- package/dist/esm/commands/logic.js +30 -20
- package/dist/esm/commands/query.d.ts +1 -1
- package/dist/esm/commands/query.js +91 -71
- package/dist/esm/commands/update.js +8 -6
- package/dist/esm/config/error.config.js +1 -1
- package/dist/esm/const/code.js +1 -1
- package/dist/esm/constant.d.ts +7 -7
- package/dist/esm/constant.js +12 -11
- package/dist/esm/document.d.ts +10 -6
- package/dist/esm/document.js +297 -185
- package/dist/esm/geo/interface.js +1 -0
- package/dist/esm/geo/lineString.d.ts +1 -1
- package/dist/esm/geo/lineString.js +57 -28
- package/dist/esm/geo/multiLineString.d.ts +1 -1
- package/dist/esm/geo/multiLineString.js +66 -27
- package/dist/esm/geo/multiPoint.d.ts +1 -1
- package/dist/esm/geo/multiPoint.js +53 -24
- package/dist/esm/geo/multiPolygon.d.ts +1 -1
- package/dist/esm/geo/multiPolygon.js +91 -31
- package/dist/esm/geo/point.d.ts +1 -1
- package/dist/esm/geo/point.js +26 -19
- package/dist/esm/geo/polygon.d.ts +1 -1
- package/dist/esm/geo/polygon.js +73 -34
- package/dist/esm/helper/symbol.js +13 -13
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/index.js +62 -9
- package/dist/esm/lib/util.d.ts +1 -0
- package/dist/esm/lib/util.js +22 -0
- package/dist/esm/operator-map.js +4 -4
- package/dist/esm/query.d.ts +8 -4
- package/dist/esm/query.js +299 -192
- package/dist/esm/regexp/index.d.ts +1 -1
- package/dist/esm/regexp/index.js +15 -8
- package/dist/esm/serializer/common.d.ts +2 -2
- package/dist/esm/serializer/common.js +49 -13
- package/dist/esm/serializer/datatype.d.ts +2 -2
- package/dist/esm/serializer/datatype.js +44 -8
- package/dist/esm/serializer/query.d.ts +1 -1
- package/dist/esm/serializer/query.js +112 -102
- package/dist/esm/serializer/update.d.ts +1 -1
- package/dist/esm/serializer/update.js +69 -64
- package/dist/esm/serverDate/index.d.ts +1 -1
- package/dist/esm/serverDate/index.js +15 -8
- package/dist/esm/transaction/collection.d.ts +7 -0
- package/dist/esm/transaction/collection.js +46 -0
- package/dist/esm/transaction/document.d.ts +27 -0
- package/dist/esm/transaction/document.js +202 -0
- package/dist/esm/transaction/index.js +191 -81
- package/dist/esm/transaction/query.d.ts +43 -0
- package/dist/esm/transaction/query.js +258 -0
- package/dist/esm/typings/index.d.ts +4 -4
- package/dist/esm/typings/index.js +1 -0
- package/dist/esm/typings/realtime.d.ts +16 -16
- package/dist/esm/typings/realtime.js +1 -0
- package/dist/esm/util.js +121 -90
- package/dist/esm/utils/error.d.ts +2 -1
- package/dist/esm/utils/error.js +70 -35
- package/dist/esm/utils/symbol.js +33 -14
- package/dist/esm/utils/type.d.ts +1 -1
- package/dist/esm/utils/type.js +12 -12
- package/dist/esm/utils/utils.d.ts +4 -1
- package/dist/esm/utils/utils.js +78 -16
- package/dist/esm/validate.js +65 -49
- package/jest.config.js +14 -0
- package/package.json +14 -10
- package/src/aggregate.ts +1 -5
- package/src/collection.ts +15 -2
- package/src/document.ts +45 -34
- package/src/index.ts +51 -4
- package/src/query.ts +33 -29
- package/src/serializer/query.ts +18 -6
- package/src/transaction/index.ts +1 -1
- package/src/typings/index.ts +0 -4
- package/src/utils/utils.ts +46 -0
- package/src/validate.ts +3 -6
- package/tests/gateway-contract.test.ts +180 -0
- package/tests/index.test.ts +283 -0
- package/tests/transaction-query.test.ts +207 -0
- package/tsconfig.esm.json +4 -2
- package/tsconfig.json +16 -6
- package/tsconfig.test.json +15 -0
- package/dist/commonjs/realtime/error.d.ts +0 -7
- package/dist/commonjs/realtime/error.js +0 -11
- package/dist/commonjs/realtime/listener.d.ts +0 -14
- package/dist/commonjs/realtime/listener.js +0 -17
- package/dist/commonjs/realtime/message.d.ts +0 -3
- package/dist/commonjs/realtime/message.js +0 -10
- package/dist/commonjs/realtime/snapshot.d.ts +0 -16
- package/dist/commonjs/realtime/snapshot.js +0 -42
- package/dist/commonjs/realtime/virtual-websocket-client.d.ts +0 -63
- package/dist/commonjs/realtime/virtual-websocket-client.js +0 -736
- package/dist/commonjs/realtime/websocket-client.d.ts +0 -78
- package/dist/commonjs/realtime/websocket-client.js +0 -567
- package/dist/commonjs/realtime/ws-event.d.ts +0 -126
- package/dist/commonjs/realtime/ws-event.js +0 -139
- package/dist/commonjs/transaction.d.ts +0 -42
- package/dist/commonjs/transaction.js +0 -126
- package/dist/esm/realtime/error.d.ts +0 -7
- package/dist/esm/realtime/error.js +0 -8
- package/dist/esm/realtime/listener.d.ts +0 -14
- package/dist/esm/realtime/listener.js +0 -14
- package/dist/esm/realtime/message.d.ts +0 -3
- package/dist/esm/realtime/message.js +0 -6
- package/dist/esm/realtime/snapshot.d.ts +0 -16
- package/dist/esm/realtime/snapshot.js +0 -39
- package/dist/esm/realtime/virtual-websocket-client.d.ts +0 -63
- package/dist/esm/realtime/virtual-websocket-client.js +0 -733
- package/dist/esm/realtime/websocket-client.d.ts +0 -78
- package/dist/esm/realtime/websocket-client.js +0 -564
- package/dist/esm/realtime/ws-event.d.ts +0 -126
- package/dist/esm/realtime/ws-event.js +0 -137
- package/dist/esm/transaction.d.ts +0 -42
- package/dist/esm/transaction.js +0 -121
- package/src/realtime/error.ts +0 -19
- package/src/realtime/listener.ts +0 -35
- package/src/realtime/message.ts +0 -14
- package/src/realtime/snapshot.ts +0 -60
- package/src/realtime/virtual-websocket-client.ts +0 -1195
- package/src/realtime/websocket-client.ts +0 -995
- package/src/realtime/ws-event.ts +0 -163
- package/src/transaction.ts +0 -190
|
@@ -1,10 +1,26 @@
|
|
|
1
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
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
exports.isComparisonCommand = exports.isKnownQueryCommand = exports.isQueryCommand = exports.QueryCommand = exports.QUERY_COMMANDS_LITERAL = exports.MOD = exports.SIZE = exports.EXISTS = exports.ELEM_MATCH = exports.ALL = exports.NIN = exports.IN = exports.LTE = exports.LT = exports.GTE = exports.GT = exports.NEQ = exports.EQ = void 0;
|
|
19
|
+
var logic_1 = require("./logic");
|
|
20
|
+
var symbol_1 = require("../helper/symbol");
|
|
21
|
+
var index_1 = require("../geo/index");
|
|
22
|
+
var type_1 = require("../utils/type");
|
|
23
|
+
var validate_1 = require("../validate");
|
|
8
24
|
exports.EQ = 'eq';
|
|
9
25
|
exports.NEQ = 'neq';
|
|
10
26
|
exports.GT = 'gt';
|
|
@@ -37,100 +53,104 @@ var QUERY_COMMANDS_LITERAL;
|
|
|
37
53
|
QUERY_COMMANDS_LITERAL["GEO_WITHIN"] = "geoWithin";
|
|
38
54
|
QUERY_COMMANDS_LITERAL["GEO_INTERSECTS"] = "geoIntersects";
|
|
39
55
|
})(QUERY_COMMANDS_LITERAL = exports.QUERY_COMMANDS_LITERAL || (exports.QUERY_COMMANDS_LITERAL = {}));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this
|
|
44
|
-
|
|
56
|
+
var QueryCommand = (function (_super) {
|
|
57
|
+
__extends(QueryCommand, _super);
|
|
58
|
+
function QueryCommand(operator, operands, fieldName) {
|
|
59
|
+
var _this = _super.call(this, operator, operands, fieldName) || this;
|
|
60
|
+
_this.operator = operator;
|
|
61
|
+
_this._internalType = symbol_1.SYMBOL_QUERY_COMMAND;
|
|
62
|
+
return _this;
|
|
45
63
|
}
|
|
46
|
-
toJSON() {
|
|
64
|
+
QueryCommand.prototype.toJSON = function () {
|
|
65
|
+
var _a, _b, _c;
|
|
47
66
|
switch (this.operator) {
|
|
48
67
|
case QUERY_COMMANDS_LITERAL.IN:
|
|
49
68
|
case QUERY_COMMANDS_LITERAL.NIN:
|
|
50
|
-
return {
|
|
51
|
-
['$' + this.operator]
|
|
52
|
-
|
|
69
|
+
return _a = {},
|
|
70
|
+
_a['$' + this.operator] = this.operands,
|
|
71
|
+
_a;
|
|
53
72
|
case QUERY_COMMANDS_LITERAL.NEQ:
|
|
54
|
-
return {
|
|
55
|
-
['$ne']
|
|
56
|
-
|
|
73
|
+
return _b = {},
|
|
74
|
+
_b['$ne'] = this.operands[0],
|
|
75
|
+
_b;
|
|
57
76
|
default:
|
|
58
|
-
return {
|
|
59
|
-
['$' + this.operator]
|
|
60
|
-
|
|
77
|
+
return _c = {},
|
|
78
|
+
_c['$' + this.operator] = this.operands[0],
|
|
79
|
+
_c;
|
|
61
80
|
}
|
|
62
|
-
}
|
|
63
|
-
_setFieldName(fieldName) {
|
|
64
|
-
|
|
81
|
+
};
|
|
82
|
+
QueryCommand.prototype._setFieldName = function (fieldName) {
|
|
83
|
+
var command = new QueryCommand(this.operator, this.operands, fieldName);
|
|
65
84
|
return command;
|
|
66
|
-
}
|
|
67
|
-
eq(val) {
|
|
68
|
-
|
|
85
|
+
};
|
|
86
|
+
QueryCommand.prototype.eq = function (val) {
|
|
87
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.EQ, [val], this.fieldName);
|
|
69
88
|
return this.and(command);
|
|
70
|
-
}
|
|
71
|
-
neq(val) {
|
|
72
|
-
|
|
89
|
+
};
|
|
90
|
+
QueryCommand.prototype.neq = function (val) {
|
|
91
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.NEQ, [val], this.fieldName);
|
|
73
92
|
return this.and(command);
|
|
74
|
-
}
|
|
75
|
-
gt(val) {
|
|
76
|
-
|
|
93
|
+
};
|
|
94
|
+
QueryCommand.prototype.gt = function (val) {
|
|
95
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GT, [val], this.fieldName);
|
|
77
96
|
return this.and(command);
|
|
78
|
-
}
|
|
79
|
-
gte(val) {
|
|
80
|
-
|
|
97
|
+
};
|
|
98
|
+
QueryCommand.prototype.gte = function (val) {
|
|
99
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GTE, [val], this.fieldName);
|
|
81
100
|
return this.and(command);
|
|
82
|
-
}
|
|
83
|
-
lt(val) {
|
|
84
|
-
|
|
101
|
+
};
|
|
102
|
+
QueryCommand.prototype.lt = function (val) {
|
|
103
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.LT, [val], this.fieldName);
|
|
85
104
|
return this.and(command);
|
|
86
|
-
}
|
|
87
|
-
lte(val) {
|
|
88
|
-
|
|
105
|
+
};
|
|
106
|
+
QueryCommand.prototype.lte = function (val) {
|
|
107
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.LTE, [val], this.fieldName);
|
|
89
108
|
return this.and(command);
|
|
90
|
-
}
|
|
91
|
-
in(list) {
|
|
92
|
-
|
|
109
|
+
};
|
|
110
|
+
QueryCommand.prototype.in = function (list) {
|
|
111
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.IN, list, this.fieldName);
|
|
93
112
|
return this.and(command);
|
|
94
|
-
}
|
|
95
|
-
nin(list) {
|
|
96
|
-
|
|
113
|
+
};
|
|
114
|
+
QueryCommand.prototype.nin = function (list) {
|
|
115
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.NIN, list, this.fieldName);
|
|
97
116
|
return this.and(command);
|
|
98
|
-
}
|
|
99
|
-
geoNear(val) {
|
|
117
|
+
};
|
|
118
|
+
QueryCommand.prototype.geoNear = function (val) {
|
|
100
119
|
if (!(val.geometry instanceof index_1.Point)) {
|
|
101
|
-
throw new TypeError(
|
|
120
|
+
throw new TypeError("\"geometry\" must be of type Point. Received type ".concat(typeof val.geometry));
|
|
102
121
|
}
|
|
103
|
-
if (val.maxDistance !== undefined && !type_1.isNumber(val.maxDistance)) {
|
|
104
|
-
throw new TypeError(
|
|
122
|
+
if (val.maxDistance !== undefined && !(0, type_1.isNumber)(val.maxDistance)) {
|
|
123
|
+
throw new TypeError("\"maxDistance\" must be of type Number. Received type ".concat(typeof val.maxDistance));
|
|
105
124
|
}
|
|
106
|
-
if (val.minDistance !== undefined && !type_1.isNumber(val.minDistance)) {
|
|
107
|
-
throw new TypeError(
|
|
125
|
+
if (val.minDistance !== undefined && !(0, type_1.isNumber)(val.minDistance)) {
|
|
126
|
+
throw new TypeError("\"minDistance\" must be of type Number. Received type ".concat(typeof val.minDistance));
|
|
108
127
|
}
|
|
109
|
-
|
|
128
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_NEAR, [val], this.fieldName);
|
|
110
129
|
return this.and(command);
|
|
111
|
-
}
|
|
112
|
-
geoWithin(val) {
|
|
130
|
+
};
|
|
131
|
+
QueryCommand.prototype.geoWithin = function (val) {
|
|
113
132
|
if (!(val.geometry instanceof index_1.MultiPolygon) &&
|
|
114
133
|
!(val.geometry instanceof index_1.Polygon) &&
|
|
115
134
|
!validate_1.Validate.isCentersPhere(val.centerSphere)) {
|
|
116
|
-
throw new TypeError(
|
|
135
|
+
throw new TypeError("\"geometry\" must be of type Polygon or MultiPolygon. Received type ".concat(typeof val.geometry));
|
|
117
136
|
}
|
|
118
|
-
|
|
137
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_WITHIN, [val], this.fieldName);
|
|
119
138
|
return this.and(command);
|
|
120
|
-
}
|
|
121
|
-
geoIntersects(val) {
|
|
139
|
+
};
|
|
140
|
+
QueryCommand.prototype.geoIntersects = function (val) {
|
|
122
141
|
if (!(val.geometry instanceof index_1.Point) &&
|
|
123
142
|
!(val.geometry instanceof index_1.LineString) &&
|
|
124
143
|
!(val.geometry instanceof index_1.Polygon) &&
|
|
125
144
|
!(val.geometry instanceof index_1.MultiPoint) &&
|
|
126
145
|
!(val.geometry instanceof index_1.MultiLineString) &&
|
|
127
146
|
!(val.geometry instanceof index_1.MultiPolygon)) {
|
|
128
|
-
throw new TypeError(
|
|
147
|
+
throw new TypeError("\"geometry\" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type ".concat(typeof val.geometry));
|
|
129
148
|
}
|
|
130
|
-
|
|
149
|
+
var command = new QueryCommand(QUERY_COMMANDS_LITERAL.GEO_INTERSECTS, [val], this.fieldName);
|
|
131
150
|
return this.and(command);
|
|
132
|
-
}
|
|
133
|
-
|
|
151
|
+
};
|
|
152
|
+
return QueryCommand;
|
|
153
|
+
}(logic_1.LogicCommand));
|
|
134
154
|
exports.QueryCommand = QueryCommand;
|
|
135
155
|
function isQueryCommand(object) {
|
|
136
156
|
return object && object instanceof QueryCommand && object._internalType === symbol_1.SYMBOL_QUERY_COMMAND;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.isKnownUpdateCommand = exports.isUpdateCommand = exports.UpdateCommand = exports.UPDATE_COMMANDS_LITERAL = void 0;
|
|
4
|
+
var symbol_1 = require("../helper/symbol");
|
|
4
5
|
var UPDATE_COMMANDS_LITERAL;
|
|
5
6
|
(function (UPDATE_COMMANDS_LITERAL) {
|
|
6
7
|
UPDATE_COMMANDS_LITERAL["SET"] = "set";
|
|
@@ -19,8 +20,8 @@ var UPDATE_COMMANDS_LITERAL;
|
|
|
19
20
|
UPDATE_COMMANDS_LITERAL["MAX"] = "max";
|
|
20
21
|
UPDATE_COMMANDS_LITERAL["MIN"] = "min";
|
|
21
22
|
})(UPDATE_COMMANDS_LITERAL = exports.UPDATE_COMMANDS_LITERAL || (exports.UPDATE_COMMANDS_LITERAL = {}));
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
var UpdateCommand = (function () {
|
|
24
|
+
function UpdateCommand(operator, operands, fieldName) {
|
|
24
25
|
this._internalType = symbol_1.SYMBOL_UPDATE_COMMAND;
|
|
25
26
|
Object.defineProperties(this, {
|
|
26
27
|
_internalType: {
|
|
@@ -32,11 +33,12 @@ class UpdateCommand {
|
|
|
32
33
|
this.operands = operands;
|
|
33
34
|
this.fieldName = fieldName || symbol_1.SYMBOL_UNSET_FIELD_NAME;
|
|
34
35
|
}
|
|
35
|
-
_setFieldName(fieldName) {
|
|
36
|
-
|
|
36
|
+
UpdateCommand.prototype._setFieldName = function (fieldName) {
|
|
37
|
+
var command = new UpdateCommand(this.operator, this.operands, fieldName);
|
|
37
38
|
return command;
|
|
38
|
-
}
|
|
39
|
-
|
|
39
|
+
};
|
|
40
|
+
return UpdateCommand;
|
|
41
|
+
}());
|
|
40
42
|
exports.UpdateCommand = UpdateCommand;
|
|
41
43
|
function isUpdateCommand(object) {
|
|
42
44
|
return object && (object instanceof UpdateCommand) && (object._internalType === symbol_1.SYMBOL_UPDATE_COMMAND);
|
|
@@ -28,9 +28,9 @@ declare const FieldType: {
|
|
|
28
28
|
ServerDate: string;
|
|
29
29
|
BsonDate: string;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
type OrderByDirection = 'desc' | 'asc';
|
|
32
32
|
declare const OrderDirectionList: string[];
|
|
33
|
-
|
|
33
|
+
type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>';
|
|
34
34
|
declare const WhereFilterOpList: string[];
|
|
35
35
|
declare enum Opeartor {
|
|
36
36
|
lt = "<",
|
|
@@ -40,11 +40,11 @@ declare enum Opeartor {
|
|
|
40
40
|
eq = "=="
|
|
41
41
|
}
|
|
42
42
|
declare const OperatorMap: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
"==": string;
|
|
44
|
+
"<": string;
|
|
45
|
+
"<=": string;
|
|
46
|
+
">": string;
|
|
47
|
+
">=": string;
|
|
48
48
|
};
|
|
49
49
|
declare const UpdateOperatorList: string[];
|
|
50
50
|
declare enum QueryType {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.QueryType = exports.UpdateOperatorList = exports.OrderDirectionList = exports.OperatorMap = exports.Opeartor = exports.WhereFilterOpList = exports.FieldType = exports.ErrorCode = void 0;
|
|
3
5
|
var ErrorCode;
|
|
4
6
|
(function (ErrorCode) {
|
|
5
7
|
ErrorCode["DocIDError"] = "\u6587\u6863ID\u4E0D\u5408\u6CD5";
|
|
@@ -14,7 +16,7 @@ var ErrorCode;
|
|
|
14
16
|
ErrorCode["CentersPhereError"] = "centersPhere\u7ED3\u6784\u4E0D\u5408\u6CD5";
|
|
15
17
|
})(ErrorCode || (ErrorCode = {}));
|
|
16
18
|
exports.ErrorCode = ErrorCode;
|
|
17
|
-
|
|
19
|
+
var FieldType = {
|
|
18
20
|
String: 'String',
|
|
19
21
|
Number: 'Number',
|
|
20
22
|
Object: 'Object',
|
|
@@ -33,9 +35,9 @@ const FieldType = {
|
|
|
33
35
|
BsonDate: 'BsonDate'
|
|
34
36
|
};
|
|
35
37
|
exports.FieldType = FieldType;
|
|
36
|
-
|
|
38
|
+
var OrderDirectionList = ['desc', 'asc'];
|
|
37
39
|
exports.OrderDirectionList = OrderDirectionList;
|
|
38
|
-
|
|
40
|
+
var WhereFilterOpList = ['<', '<=', '==', '>=', '>'];
|
|
39
41
|
exports.WhereFilterOpList = WhereFilterOpList;
|
|
40
42
|
var Opeartor;
|
|
41
43
|
(function (Opeartor) {
|
|
@@ -46,15 +48,15 @@ var Opeartor;
|
|
|
46
48
|
Opeartor["eq"] = "==";
|
|
47
49
|
})(Opeartor || (Opeartor = {}));
|
|
48
50
|
exports.Opeartor = Opeartor;
|
|
49
|
-
|
|
50
|
-
[Opeartor.eq]
|
|
51
|
-
[Opeartor.lt]
|
|
52
|
-
[Opeartor.lte]
|
|
53
|
-
[Opeartor.gt]
|
|
54
|
-
[Opeartor.gte]
|
|
55
|
-
|
|
51
|
+
var OperatorMap = (_a = {},
|
|
52
|
+
_a[Opeartor.eq] = '$eq',
|
|
53
|
+
_a[Opeartor.lt] = '$lt',
|
|
54
|
+
_a[Opeartor.lte] = '$lte',
|
|
55
|
+
_a[Opeartor.gt] = '$gt',
|
|
56
|
+
_a[Opeartor.gte] = '$gte',
|
|
57
|
+
_a);
|
|
56
58
|
exports.OperatorMap = OperatorMap;
|
|
57
|
-
|
|
59
|
+
var UpdateOperatorList = [
|
|
58
60
|
'$set',
|
|
59
61
|
'$inc',
|
|
60
62
|
'$mul',
|
|
@@ -2,13 +2,17 @@ import { IWatchOptions, DBRealtimeListener } from './typings/index';
|
|
|
2
2
|
export declare class DocumentReference {
|
|
3
3
|
readonly id: string | number;
|
|
4
4
|
readonly _transactionId: string;
|
|
5
|
-
readonly projection: Object;
|
|
6
5
|
private _apiOptions;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
private _create;
|
|
7
|
+
set(data: Object, callback?: any): Promise<any>;
|
|
8
|
+
private _set;
|
|
9
|
+
update(data: Object, callback?: any): Promise<any>;
|
|
10
|
+
private _update;
|
|
11
|
+
delete(callback?: any): Promise<any>;
|
|
12
|
+
remove(callback?: any): Promise<any>;
|
|
13
|
+
private _remove;
|
|
14
|
+
get(callback?: any): Promise<any>;
|
|
15
|
+
private _get;
|
|
12
16
|
field(projection: Object): DocumentReference;
|
|
13
17
|
watch: (options: IWatchOptions) => DBRealtimeListener;
|
|
14
18
|
}
|