@cloudbase/database 0.9.18-next → 0.9.20

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.
Files changed (96) hide show
  1. package/.trunk/configs/.markdownlint.yaml +10 -0
  2. package/.trunk/trunk.yaml +26 -0
  3. package/README.md +32 -10
  4. package/dist/commonjs/aggregate.js +10 -0
  5. package/dist/commonjs/document.js +1 -4
  6. package/dist/commonjs/query.js +6 -6
  7. package/package.json +2 -3
  8. package/src/aggregate.ts +11 -0
  9. package/src/document.ts +1 -4
  10. package/src/query.ts +3 -3
  11. package/dist/esm/aggregate.d.ts +0 -29
  12. package/dist/esm/aggregate.js +0 -144
  13. package/dist/esm/collection.d.ts +0 -9
  14. package/dist/esm/collection.js +0 -44
  15. package/dist/esm/command.d.ts +0 -175
  16. package/dist/esm/command.js +0 -296
  17. package/dist/esm/commands/logic.d.ts +0 -24
  18. package/dist/esm/commands/logic.js +0 -84
  19. package/dist/esm/commands/query.d.ts +0 -68
  20. package/dist/esm/commands/query.js +0 -152
  21. package/dist/esm/commands/update.d.ts +0 -29
  22. package/dist/esm/commands/update.js +0 -46
  23. package/dist/esm/config/app.config.d.ts +0 -6
  24. package/dist/esm/config/app.config.js +0 -5
  25. package/dist/esm/config/error.config.d.ts +0 -3
  26. package/dist/esm/config/error.config.js +0 -13
  27. package/dist/esm/const/code.d.ts +0 -30
  28. package/dist/esm/const/code.js +0 -30
  29. package/dist/esm/constant.d.ts +0 -51
  30. package/dist/esm/constant.js +0 -65
  31. package/dist/esm/document.d.ts +0 -11
  32. package/dist/esm/document.js +0 -250
  33. package/dist/esm/geo/index.d.ts +0 -6
  34. package/dist/esm/geo/index.js +0 -6
  35. package/dist/esm/geo/interface.d.ts +0 -24
  36. package/dist/esm/geo/interface.js +0 -0
  37. package/dist/esm/geo/lineString.d.ts +0 -19
  38. package/dist/esm/geo/lineString.js +0 -83
  39. package/dist/esm/geo/multiLineString.d.ts +0 -18
  40. package/dist/esm/geo/multiLineString.js +0 -92
  41. package/dist/esm/geo/multiPoint.d.ts +0 -18
  42. package/dist/esm/geo/multiPoint.js +0 -76
  43. package/dist/esm/geo/multiPolygon.d.ts +0 -18
  44. package/dist/esm/geo/multiPolygon.js +0 -119
  45. package/dist/esm/geo/point.d.ts +0 -19
  46. package/dist/esm/geo/point.js +0 -47
  47. package/dist/esm/geo/polygon.d.ts +0 -19
  48. package/dist/esm/geo/polygon.js +0 -106
  49. package/dist/esm/helper/symbol.d.ts +0 -14
  50. package/dist/esm/helper/symbol.js +0 -14
  51. package/dist/esm/index.d.ts +0 -33
  52. package/dist/esm/index.js +0 -41
  53. package/dist/esm/lib/util.d.ts +0 -1
  54. package/dist/esm/lib/util.js +0 -23
  55. package/dist/esm/operator-map.d.ts +0 -4
  56. package/dist/esm/operator-map.js +0 -20
  57. package/dist/esm/query.d.ts +0 -22
  58. package/dist/esm/query.js +0 -249
  59. package/dist/esm/regexp/index.d.ts +0 -14
  60. package/dist/esm/regexp/index.js +0 -29
  61. package/dist/esm/serializer/common.d.ts +0 -11
  62. package/dist/esm/serializer/common.js +0 -113
  63. package/dist/esm/serializer/datatype.d.ts +0 -7
  64. package/dist/esm/serializer/datatype.js +0 -122
  65. package/dist/esm/serializer/query.d.ts +0 -7
  66. package/dist/esm/serializer/query.js +0 -229
  67. package/dist/esm/serializer/update.d.ts +0 -15
  68. package/dist/esm/serializer/update.js +0 -139
  69. package/dist/esm/serverDate/index.d.ts +0 -13
  70. package/dist/esm/serverDate/index.js +0 -26
  71. package/dist/esm/transaction/collection.d.ts +0 -7
  72. package/dist/esm/transaction/collection.js +0 -44
  73. package/dist/esm/transaction/document.d.ts +0 -27
  74. package/dist/esm/transaction/document.js +0 -203
  75. package/dist/esm/transaction/index.d.ts +0 -30
  76. package/dist/esm/transaction/index.js +0 -210
  77. package/dist/esm/transaction/query.d.ts +0 -5
  78. package/dist/esm/transaction/query.js +0 -8
  79. package/dist/esm/typings/index.d.ts +0 -40
  80. package/dist/esm/typings/index.js +0 -0
  81. package/dist/esm/typings/realtime.d.ts +0 -219
  82. package/dist/esm/typings/realtime.js +0 -0
  83. package/dist/esm/util.d.ts +0 -9
  84. package/dist/esm/util.js +0 -142
  85. package/dist/esm/utils/error.d.ts +0 -37
  86. package/dist/esm/utils/error.js +0 -82
  87. package/dist/esm/utils/msg.d.ts +0 -0
  88. package/dist/esm/utils/msg.js +0 -0
  89. package/dist/esm/utils/symbol.d.ts +0 -8
  90. package/dist/esm/utils/symbol.js +0 -55
  91. package/dist/esm/utils/type.d.ts +0 -13
  92. package/dist/esm/utils/type.js +0 -20
  93. package/dist/esm/utils/utils.d.ts +0 -4
  94. package/dist/esm/utils/utils.js +0 -33
  95. package/dist/esm/validate.d.ts +0 -1
  96. package/dist/esm/validate.js +0 -57
@@ -0,0 +1,10 @@
1
+ # Autoformatter friendly markdownlint config (all formatting rules disabled)
2
+ default: true
3
+ blank_lines: false
4
+ bullet: false
5
+ html: false
6
+ indentation: false
7
+ line_length: false
8
+ spaces: false
9
+ url: false
10
+ whitespace: false
@@ -0,0 +1,26 @@
1
+ version: 0.1
2
+ cli:
3
+ version: 1.4.1
4
+ plugins:
5
+ sources:
6
+ - id: trunk
7
+ ref: v0.0.10
8
+ uri: https://github.com/trunk-io/plugins
9
+ lint:
10
+ enabled:
11
+ - eslint@8.33.0
12
+ - markdownlint@0.33.0
13
+ - git-diff-check
14
+ - gitleaks@8.15.3
15
+ - prettier@2.8.4
16
+ runtimes:
17
+ enabled:
18
+ - go@1.18.3
19
+ - node@18.12.1
20
+ actions:
21
+ disabled:
22
+ - trunk-announce
23
+ - trunk-check-pre-push
24
+ - trunk-fmt-pre-commit
25
+ enabled:
26
+ - trunk-upgrade-available
package/README.md CHANGED
@@ -15,7 +15,7 @@ yarn add @cloudbase/database
15
15
 
16
16
  ## 使用
17
17
 
18
- 使用 `@cloudbase/database` 时,需要提供发送请求的类 `reqClass`。
18
+ 使用 `@cloudbase/database` 时,需要提供发送请求的类 `reqClass`。
19
19
 
20
20
  ```js
21
21
  // index.js
@@ -38,23 +38,23 @@ class Tcb {
38
38
  // request.js
39
39
 
40
40
  // 进一步处理,鉴权等...
41
- const requestHandler = require('requestHandler');
41
+ const requestHandler = require('requestHandler')
42
42
 
43
43
  class Request {
44
44
  constructor(config) {
45
- this.config = config;
45
+ this.config = config
46
46
  }
47
47
 
48
48
  async send(action, data) {
49
49
  const params = Object.assign({}, data, {
50
50
  action
51
- });
51
+ })
52
52
 
53
53
  const slowQueryWarning = setTimeout(() => {
54
54
  console.warn(
55
55
  'Database operation is longer than 3s. Please check query performance and your network environment.'
56
- );
57
- }, 3000);
56
+ )
57
+ }, 3000)
58
58
 
59
59
  try {
60
60
  return await requestHandler({
@@ -65,14 +65,14 @@ class Request {
65
65
  headers: {
66
66
  'content-type': 'application/json'
67
67
  }
68
- });
68
+ })
69
69
  } finally {
70
- clearTimeout(slowQueryWarning);
70
+ clearTimeout(slowQueryWarning)
71
71
  }
72
72
  }
73
73
  }
74
74
 
75
- module.exports = Request;
75
+ module.exports = Request
76
76
  ```
77
77
 
78
78
  请求数据样例
@@ -94,4 +94,26 @@ module.exports = Request;
94
94
  },
95
95
  "json": true
96
96
  }
97
- ```
97
+ ```
98
+
99
+ ## 开发指南
100
+
101
+ ### 注意
102
+
103
+ 当前 database 库是通过分支来控制了两个不同的版本,主干版提供给@cloudbase/js-sdk 库使用,feature/support_db_2.0 分支提供给@cloudbase/node-sdk 库使用。
104
+
105
+ 两个分支区别:
106
+ support_db_2.0 分支进行了数据库接口的升级,将原有的 json 协议转换为 mongo 支持的 bson 协议处理,目的是解决旧接口存在的问题,描述如下
107
+
108
+ - 日期对象 是走约定协议处理,即转换为 {$date: timestamp},这种方式应摒弃(EJSON 协议可解决)
109
+ - 无法支持 null, NaN 等特殊类型处理(EJSON 协议可解决)
110
+ - serverDate 这种自定义类型的实现,是继续保留 还是摒弃
111
+ - 接口实现混杂,普通 CRUD 接口均走 flexdb,而聚合,事务又用 runcommand 方式
112
+ - 原插入文档接口返回 docId 形式混杂
113
+
114
+ 目前仅针对服务端 sdk @cloudbase/node-sdk 完成了升级,而客户端 sdk @cloudbase/js-sdk 以及 小程序端 SDK 仍保留为旧接口形式。
115
+
116
+ ### 开发及发布事项
117
+
118
+ 1. 数据库接口的改动务必补充测试用例验证
119
+ 2. 发布时,约定 feature/support_db_2.0 分支上发布正式版(for @cloudbase/node-sdk)使用,master 分支上发布 beta 版 (for @cloudbase/js-sdk)使用。两 sdk 均通过锁版本方式依赖该库,不会受自动更新依赖影响。
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var index_1 = require("./index");
40
40
  var bson_1 = require("bson");
41
41
  var query_1 = require("./serializer/query");
42
+ var geo_1 = require("./geo");
42
43
  var Aggregation = (function () {
43
44
  function Aggregation(db, collectionName) {
44
45
  this._stages = [];
@@ -106,6 +107,15 @@ var Aggregation = (function () {
106
107
  return this._pipe('count', param);
107
108
  };
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
+ }
109
119
  return this._pipe('geoNear', param);
110
120
  };
111
121
  Aggregation.prototype.group = function (param) {
@@ -224,10 +224,7 @@ var DocumentReference = (function () {
224
224
  var documents = util_2.Util.formatResDocumentData(res.data.list);
225
225
  callback(0, {
226
226
  data: documents,
227
- requestId: res.requestId,
228
- total: res.TotalCount,
229
- limit: res.Limit,
230
- offset: res.Offset
227
+ requestId: res.requestId
231
228
  });
232
229
  }
233
230
  })
@@ -81,12 +81,12 @@ var Query = (function () {
81
81
  data: documents,
82
82
  requestId: res.requestId
83
83
  };
84
- if (res.TotalCount)
85
- result.total = res.TotalCount;
86
- if (res.Limit)
87
- result.limit = res.Limit;
88
- if (res.Offset)
89
- result.offset = res.Offset;
84
+ if (res.total)
85
+ result.total = res.total;
86
+ if (res.limit)
87
+ result.limit = res.limit;
88
+ if (res.offset)
89
+ result.offset = res.offset;
90
90
  callback(0, result);
91
91
  }
92
92
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/database",
3
- "version": "0.9.18-next",
3
+ "version": "0.9.20",
4
4
  "description": "database for (node.)js sdk ",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -11,8 +11,7 @@
11
11
  "eslint": "eslint \"./**/*.ts\"",
12
12
  "eslint-fix": "eslint --fix \"./**/*.ts\"",
13
13
  "test": "echo \"Error: no test specified\" && exit 1",
14
- "build": "tsc -p tsconfig.json && tsc -p tsconfig.esm.json",
15
- "prepublishOnly": "npm run build"
14
+ "build": "npx tsc -p tsconfig.json && npx tsc -p tsconfig.esm.json"
16
15
  },
17
16
  "author": "",
18
17
  "license": "ISC",
package/src/aggregate.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Db } from './index'
2
2
  import { EJSON } from 'bson'
3
3
  import { QuerySerializer } from './serializer/query'
4
+ import { Point } from './geo'
4
5
  export default class Aggregation {
5
6
  _db: any
6
7
  _request: any
@@ -70,6 +71,16 @@ export default class Aggregation {
70
71
  }
71
72
 
72
73
  geoNear(param) {
74
+ if (param.query) {
75
+ param.query = QuerySerializer.encode(param.query)
76
+ }
77
+ if (param.distanceMultiplier && typeof (param.distanceMultiplier) === 'number') {
78
+ param.distanceMultiplier = param.distanceMultiplier
79
+ }
80
+
81
+ if(param.near) {
82
+ param.near = new Point(param.near.longitude, param.near.latitude).toJSON()
83
+ }
73
84
  return this._pipe('geoNear', param)
74
85
  }
75
86
 
package/src/document.ts CHANGED
@@ -301,10 +301,7 @@ export class DocumentReference {
301
301
  const documents = Util.formatResDocumentData(res.data.list)
302
302
  callback(0, {
303
303
  data: documents,
304
- requestId: res.requestId,
305
- total: res.TotalCount,
306
- limit: res.Limit,
307
- offset: res.Offset
304
+ requestId: res.requestId
308
305
  })
309
306
  }
310
307
  })
package/src/query.ts CHANGED
@@ -204,9 +204,9 @@ export class Query {
204
204
  data: documents,
205
205
  requestId: res.requestId
206
206
  }
207
- if (res.TotalCount) result.total = res.TotalCount
208
- if (res.Limit) result.limit = res.Limit
209
- if (res.Offset) result.offset = res.Offset
207
+ if (res.total) result.total = res.total
208
+ if (res.limit) result.limit = res.limit
209
+ if (res.offset) result.offset = res.offset
210
210
  callback(0, result)
211
211
  }
212
212
  })
@@ -1,29 +0,0 @@
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
- }
@@ -1,144 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { Db } from './index';
38
- import { EJSON } from 'bson';
39
- import { QuerySerializer } from './serializer/query';
40
- var Aggregation = (function () {
41
- function Aggregation(db, collectionName) {
42
- this._stages = [];
43
- if (db && collectionName) {
44
- this._db = db;
45
- this._request = new Db.reqClass(this._db.config);
46
- this._collectionName = collectionName;
47
- }
48
- }
49
- Aggregation.prototype.end = function () {
50
- return __awaiter(this, void 0, void 0, function () {
51
- var result;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- if (!this._collectionName || !this._db) {
56
- throw new Error('Aggregation pipeline cannot send request');
57
- }
58
- return [4, this._request.send('database.aggregate', {
59
- collectionName: this._collectionName,
60
- stages: this._stages
61
- })];
62
- case 1:
63
- result = _a.sent();
64
- if (result && result.data && result.data.list) {
65
- return [2, {
66
- requestId: result.requestId,
67
- data: JSON.parse(result.data.list).map(EJSON.parse)
68
- }];
69
- }
70
- return [2, result];
71
- }
72
- });
73
- });
74
- };
75
- Aggregation.prototype.unwrap = function () {
76
- return this._stages;
77
- };
78
- Aggregation.prototype.done = function () {
79
- return this._stages.map(function (_a) {
80
- var _b;
81
- var stageKey = _a.stageKey, stageValue = _a.stageValue;
82
- return _b = {},
83
- _b[stageKey] = JSON.parse(stageValue),
84
- _b;
85
- });
86
- };
87
- Aggregation.prototype._pipe = function (stage, param) {
88
- this._stages.push({
89
- stageKey: "$" + stage,
90
- stageValue: JSON.stringify(param)
91
- });
92
- return this;
93
- };
94
- Aggregation.prototype.addFields = function (param) {
95
- return this._pipe('addFields', param);
96
- };
97
- Aggregation.prototype.bucket = function (param) {
98
- return this._pipe('bucket', param);
99
- };
100
- Aggregation.prototype.bucketAuto = function (param) {
101
- return this._pipe('bucketAuto', param);
102
- };
103
- Aggregation.prototype.count = function (param) {
104
- return this._pipe('count', param);
105
- };
106
- Aggregation.prototype.geoNear = function (param) {
107
- return this._pipe('geoNear', param);
108
- };
109
- Aggregation.prototype.group = function (param) {
110
- return this._pipe('group', param);
111
- };
112
- Aggregation.prototype.limit = function (param) {
113
- return this._pipe('limit', param);
114
- };
115
- Aggregation.prototype.match = function (param) {
116
- return this._pipe('match', QuerySerializer.encode(param));
117
- };
118
- Aggregation.prototype.project = function (param) {
119
- return this._pipe('project', param);
120
- };
121
- Aggregation.prototype.lookup = function (param) {
122
- return this._pipe('lookup', param);
123
- };
124
- Aggregation.prototype.replaceRoot = function (param) {
125
- return this._pipe('replaceRoot', param);
126
- };
127
- Aggregation.prototype.sample = function (param) {
128
- return this._pipe('sample', param);
129
- };
130
- Aggregation.prototype.skip = function (param) {
131
- return this._pipe('skip', param);
132
- };
133
- Aggregation.prototype.sort = function (param) {
134
- return this._pipe('sort', param);
135
- };
136
- Aggregation.prototype.sortByCount = function (param) {
137
- return this._pipe('sortByCount', param);
138
- };
139
- Aggregation.prototype.unwind = function (param) {
140
- return this._pipe('unwind', param);
141
- };
142
- return Aggregation;
143
- }());
144
- export default Aggregation;
@@ -1,9 +0,0 @@
1
- import { DocumentReference } from './document';
2
- import { Query } from './query';
3
- import Aggregation from './aggregate';
4
- export declare class CollectionReference extends Query {
5
- readonly name: string;
6
- doc(docID?: string | number): DocumentReference;
7
- add(data: Object, callback?: any): Promise<any>;
8
- aggregate(): Aggregation;
9
- }
@@ -1,44 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- extendStatics(d, b);
10
- function __() { this.constructor = d; }
11
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
- };
13
- })();
14
- import { DocumentReference } from './document';
15
- import { Query } from './query';
16
- import Aggregation from './aggregate';
17
- var CollectionReference = (function (_super) {
18
- __extends(CollectionReference, _super);
19
- function CollectionReference(db, coll) {
20
- return _super.call(this, db, coll) || this;
21
- }
22
- Object.defineProperty(CollectionReference.prototype, "name", {
23
- get: function () {
24
- return this._coll;
25
- },
26
- enumerable: true,
27
- configurable: true
28
- });
29
- CollectionReference.prototype.doc = function (docID) {
30
- if (typeof docID !== 'string' && typeof docID !== 'number') {
31
- throw new Error('docId必须为字符串或数字');
32
- }
33
- return new DocumentReference(this._db, this._coll, docID);
34
- };
35
- CollectionReference.prototype.add = function (data, callback) {
36
- var docRef = new DocumentReference(this._db, this._coll, undefined);
37
- return docRef.create(data, callback);
38
- };
39
- CollectionReference.prototype.aggregate = function () {
40
- return new Aggregation(this._db, this._coll);
41
- };
42
- return CollectionReference;
43
- }(Query));
44
- export { CollectionReference };
@@ -1,175 +0,0 @@
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 declare 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__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
24
- nor(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
25
- or(...__expressions__: import("./serializer/datatype").IQueryCondition[]): LogicCommand;
26
- not(...__expressions__: import("./serializer/datatype").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;