@opra/mongodb 0.23.2 → 0.24.1

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/cjs/index.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./mongo-adapter.js"), exports);
5
- tslib_1.__exportStar(require("./mongo-collection-resource.js"), exports);
5
+ tslib_1.__exportStar(require("./mongo-collection.js"), exports);
6
6
  tslib_1.__exportStar(require("./mongo-entity-service.js"), exports);
7
- tslib_1.__exportStar(require("./mongo-singleton-resource.js"), exports);
7
+ tslib_1.__exportStar(require("./mongo-singleton.js"), exports);
@@ -20,22 +20,22 @@ var MongoAdapter;
20
20
  function transformRequest(request) {
21
21
  const { resource } = request;
22
22
  if (resource instanceof common_1.Collection || resource instanceof common_1.Singleton) {
23
- const { params, operation } = request;
23
+ const { params, endpoint } = request;
24
24
  let options = {};
25
25
  let filter;
26
- if (operation === 'create' || operation === 'update' ||
27
- operation === 'get' || operation === 'findMany') {
26
+ if (endpoint === 'create' || endpoint === 'update' ||
27
+ endpoint === 'get' || endpoint === 'findMany') {
28
28
  options.projection = MongoAdapter.transformProjection(resource.type, params);
29
29
  }
30
30
  if (resource instanceof common_1.Collection &&
31
- (operation === 'delete' || operation === 'get' || operation === 'update')) {
31
+ (endpoint === 'delete' || endpoint === 'get' || endpoint === 'update')) {
32
32
  filter = MongoAdapter.transformKeyValues(resource, request.key);
33
33
  }
34
34
  if (params?.filter) {
35
35
  const f = MongoAdapter.transformFilter(params.filter);
36
36
  filter = filter ? { $and: [filter, f] } : f;
37
37
  }
38
- if (operation === 'findMany') {
38
+ if (endpoint === 'findMany') {
39
39
  options.sort = params?.sort;
40
40
  options.limit = params?.limit;
41
41
  options.skip = params?.skip;
@@ -43,7 +43,7 @@ var MongoAdapter;
43
43
  options.count = params?.count;
44
44
  }
45
45
  options = (0, lodash_omitby_1.default)(options, lodash_isnil_1.default);
46
- switch (operation) {
46
+ switch (endpoint) {
47
47
  case 'create': {
48
48
  return {
49
49
  method: 'insertOne',
@@ -55,7 +55,7 @@ var MongoAdapter;
55
55
  case 'delete':
56
56
  case 'deleteMany': {
57
57
  return {
58
- method: (operation === 'delete' ? 'deleteOne' : 'deleteMany'),
58
+ method: (endpoint === 'delete' ? 'deleteOne' : 'deleteMany'),
59
59
  filter,
60
60
  options,
61
61
  args: [filter, options]
@@ -102,7 +102,7 @@ var MongoAdapter;
102
102
  }
103
103
  }
104
104
  }
105
- throw new TypeError(`Unimplemented request kind (${request.resource.kind}.${request.operation})`);
105
+ throw new TypeError(`Unimplemented request kind (${request.resource.kind}.${request.endpoint})`);
106
106
  }
107
107
  MongoAdapter.transformRequest = transformRequest;
108
108
  })(MongoAdapter || (exports.MongoAdapter = MongoAdapter = {}));
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MongoCollectionResource = void 0;
3
+ exports.MongoCollection = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@opra/common");
6
- const core_1 = require("@opra/core");
7
6
  const mongo_adapter_js_1 = require("./mongo-adapter.js");
8
7
  // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
9
- class MongoCollectionResource {
8
+ class MongoCollection {
10
9
  constructor(options) {
11
10
  this.defaultLimit = options?.defaultLimit || 100;
12
11
  }
@@ -54,46 +53,25 @@ class MongoCollectionResource {
54
53
  return service.find(prepared.filter, prepared.options);
55
54
  }
56
55
  }
57
- exports.MongoCollectionResource = MongoCollectionResource;
56
+ exports.MongoCollection = MongoCollection;
58
57
  tslib_1.__decorate([
59
- common_1.Collection.Create(),
60
- tslib_1.__metadata("design:type", Function),
61
- tslib_1.__metadata("design:paramtypes", [Object]),
62
- tslib_1.__metadata("design:returntype", Promise)
63
- ], MongoCollectionResource.prototype, "create", null);
58
+ common_1.Collection.Create()
59
+ ], MongoCollection.prototype, "create", null);
64
60
  tslib_1.__decorate([
65
- common_1.Collection.Delete(),
66
- tslib_1.__metadata("design:type", Function),
67
- tslib_1.__metadata("design:paramtypes", [Object]),
68
- tslib_1.__metadata("design:returntype", Promise)
69
- ], MongoCollectionResource.prototype, "delete", null);
61
+ common_1.Collection.Delete()
62
+ ], MongoCollection.prototype, "delete", null);
70
63
  tslib_1.__decorate([
71
- common_1.Collection.DeleteMany(),
72
- tslib_1.__metadata("design:type", Function),
73
- tslib_1.__metadata("design:paramtypes", [Object]),
74
- tslib_1.__metadata("design:returntype", Promise)
75
- ], MongoCollectionResource.prototype, "deleteMany", null);
64
+ common_1.Collection.DeleteMany()
65
+ ], MongoCollection.prototype, "deleteMany", null);
76
66
  tslib_1.__decorate([
77
- common_1.Collection.Get(),
78
- tslib_1.__metadata("design:type", Function),
79
- tslib_1.__metadata("design:paramtypes", [Object]),
80
- tslib_1.__metadata("design:returntype", Promise)
81
- ], MongoCollectionResource.prototype, "get", null);
67
+ common_1.Collection.Get()
68
+ ], MongoCollection.prototype, "get", null);
82
69
  tslib_1.__decorate([
83
- common_1.Collection.Update(),
84
- tslib_1.__metadata("design:type", Function),
85
- tslib_1.__metadata("design:paramtypes", [Object]),
86
- tslib_1.__metadata("design:returntype", Promise)
87
- ], MongoCollectionResource.prototype, "update", null);
70
+ common_1.Collection.Update()
71
+ ], MongoCollection.prototype, "update", null);
88
72
  tslib_1.__decorate([
89
- common_1.Collection.UpdateMany(),
90
- tslib_1.__metadata("design:type", Function),
91
- tslib_1.__metadata("design:paramtypes", [Object]),
92
- tslib_1.__metadata("design:returntype", Promise)
93
- ], MongoCollectionResource.prototype, "updateMany", null);
73
+ common_1.Collection.UpdateMany()
74
+ ], MongoCollection.prototype, "updateMany", null);
94
75
  tslib_1.__decorate([
95
- common_1.Collection.FindMany(),
96
- tslib_1.__metadata("design:type", Function),
97
- tslib_1.__metadata("design:paramtypes", [Object]),
98
- tslib_1.__metadata("design:returntype", Promise)
99
- ], MongoCollectionResource.prototype, "findMany", null);
76
+ common_1.Collection.FindMany()
77
+ ], MongoCollection.prototype, "findMany", null);
@@ -123,7 +123,7 @@ class MongoEntityService {
123
123
  if (this.transformData)
124
124
  out = this.transformData(out);
125
125
  if (!out)
126
- throw new Error('"insertOne" operation returned no result!');
126
+ throw new Error('"insertOne" endpoint returned no result!');
127
127
  return out;
128
128
  }
129
129
  async updateOne(filter, doc, options) {
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MongoSingletonResource = void 0;
3
+ exports.MongoSingleton = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@opra/common");
6
- const core_1 = require("@opra/core");
7
6
  const mongo_adapter_js_1 = require("./mongo-adapter.js");
8
- class MongoSingletonResource {
7
+ class MongoSingleton {
9
8
  constructor() {
10
9
  this.defaultLimit = 100;
11
10
  }
@@ -31,28 +30,16 @@ class MongoSingletonResource {
31
30
  return service.updateOne(prepared.filter, prepared.update, prepared.options);
32
31
  }
33
32
  }
34
- exports.MongoSingletonResource = MongoSingletonResource;
33
+ exports.MongoSingleton = MongoSingleton;
35
34
  tslib_1.__decorate([
36
- common_1.Singleton.Create(),
37
- tslib_1.__metadata("design:type", Function),
38
- tslib_1.__metadata("design:paramtypes", [Object]),
39
- tslib_1.__metadata("design:returntype", Promise)
40
- ], MongoSingletonResource.prototype, "create", null);
35
+ common_1.Singleton.Create()
36
+ ], MongoSingleton.prototype, "create", null);
41
37
  tslib_1.__decorate([
42
- common_1.Singleton.Delete(),
43
- tslib_1.__metadata("design:type", Function),
44
- tslib_1.__metadata("design:paramtypes", [Object]),
45
- tslib_1.__metadata("design:returntype", Promise)
46
- ], MongoSingletonResource.prototype, "delete", null);
38
+ common_1.Singleton.Delete()
39
+ ], MongoSingleton.prototype, "delete", null);
47
40
  tslib_1.__decorate([
48
- common_1.Singleton.Get(),
49
- tslib_1.__metadata("design:type", Function),
50
- tslib_1.__metadata("design:paramtypes", [Object]),
51
- tslib_1.__metadata("design:returntype", Promise)
52
- ], MongoSingletonResource.prototype, "get", null);
41
+ common_1.Singleton.Get()
42
+ ], MongoSingleton.prototype, "get", null);
53
43
  tslib_1.__decorate([
54
- common_1.Singleton.Update(),
55
- tslib_1.__metadata("design:type", Function),
56
- tslib_1.__metadata("design:paramtypes", [Object]),
57
- tslib_1.__metadata("design:returntype", Promise)
58
- ], MongoSingletonResource.prototype, "update", null);
44
+ common_1.Singleton.Update()
45
+ ], MongoSingleton.prototype, "update", null);
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './mongo-adapter.js';
2
- export * from './mongo-collection-resource.js';
2
+ export * from './mongo-collection.js';
3
3
  export * from './mongo-entity-service.js';
4
- export * from './mongo-singleton-resource.js';
4
+ export * from './mongo-singleton.js';
@@ -16,22 +16,22 @@ export var MongoAdapter;
16
16
  function transformRequest(request) {
17
17
  const { resource } = request;
18
18
  if (resource instanceof Collection || resource instanceof Singleton) {
19
- const { params, operation } = request;
19
+ const { params, endpoint } = request;
20
20
  let options = {};
21
21
  let filter;
22
- if (operation === 'create' || operation === 'update' ||
23
- operation === 'get' || operation === 'findMany') {
22
+ if (endpoint === 'create' || endpoint === 'update' ||
23
+ endpoint === 'get' || endpoint === 'findMany') {
24
24
  options.projection = MongoAdapter.transformProjection(resource.type, params);
25
25
  }
26
26
  if (resource instanceof Collection &&
27
- (operation === 'delete' || operation === 'get' || operation === 'update')) {
27
+ (endpoint === 'delete' || endpoint === 'get' || endpoint === 'update')) {
28
28
  filter = MongoAdapter.transformKeyValues(resource, request.key);
29
29
  }
30
30
  if (params?.filter) {
31
31
  const f = MongoAdapter.transformFilter(params.filter);
32
32
  filter = filter ? { $and: [filter, f] } : f;
33
33
  }
34
- if (operation === 'findMany') {
34
+ if (endpoint === 'findMany') {
35
35
  options.sort = params?.sort;
36
36
  options.limit = params?.limit;
37
37
  options.skip = params?.skip;
@@ -39,7 +39,7 @@ export var MongoAdapter;
39
39
  options.count = params?.count;
40
40
  }
41
41
  options = omitBy(options, isNil);
42
- switch (operation) {
42
+ switch (endpoint) {
43
43
  case 'create': {
44
44
  return {
45
45
  method: 'insertOne',
@@ -51,7 +51,7 @@ export var MongoAdapter;
51
51
  case 'delete':
52
52
  case 'deleteMany': {
53
53
  return {
54
- method: (operation === 'delete' ? 'deleteOne' : 'deleteMany'),
54
+ method: (endpoint === 'delete' ? 'deleteOne' : 'deleteMany'),
55
55
  filter,
56
56
  options,
57
57
  args: [filter, options]
@@ -98,7 +98,7 @@ export var MongoAdapter;
98
98
  }
99
99
  }
100
100
  }
101
- throw new TypeError(`Unimplemented request kind (${request.resource.kind}.${request.operation})`);
101
+ throw new TypeError(`Unimplemented request kind (${request.resource.kind}.${request.endpoint})`);
102
102
  }
103
103
  MongoAdapter.transformRequest = transformRequest;
104
104
  })(MongoAdapter || (MongoAdapter = {}));
@@ -1,9 +1,8 @@
1
- import { __decorate, __metadata } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { Collection } from '@opra/common';
3
- import { OperationContext } from '@opra/core';
4
3
  import { MongoAdapter } from './mongo-adapter.js';
5
4
  // noinspection TypeScriptAbstractClassConstructorCanBeMadeProtected
6
- export class MongoCollectionResource {
5
+ export class MongoCollection {
7
6
  constructor(options) {
8
7
  this.defaultLimit = options?.defaultLimit || 100;
9
8
  }
@@ -52,44 +51,23 @@ export class MongoCollectionResource {
52
51
  }
53
52
  }
54
53
  __decorate([
55
- Collection.Create(),
56
- __metadata("design:type", Function),
57
- __metadata("design:paramtypes", [Object]),
58
- __metadata("design:returntype", Promise)
59
- ], MongoCollectionResource.prototype, "create", null);
54
+ Collection.Create()
55
+ ], MongoCollection.prototype, "create", null);
60
56
  __decorate([
61
- Collection.Delete(),
62
- __metadata("design:type", Function),
63
- __metadata("design:paramtypes", [Object]),
64
- __metadata("design:returntype", Promise)
65
- ], MongoCollectionResource.prototype, "delete", null);
57
+ Collection.Delete()
58
+ ], MongoCollection.prototype, "delete", null);
66
59
  __decorate([
67
- Collection.DeleteMany(),
68
- __metadata("design:type", Function),
69
- __metadata("design:paramtypes", [Object]),
70
- __metadata("design:returntype", Promise)
71
- ], MongoCollectionResource.prototype, "deleteMany", null);
60
+ Collection.DeleteMany()
61
+ ], MongoCollection.prototype, "deleteMany", null);
72
62
  __decorate([
73
- Collection.Get(),
74
- __metadata("design:type", Function),
75
- __metadata("design:paramtypes", [Object]),
76
- __metadata("design:returntype", Promise)
77
- ], MongoCollectionResource.prototype, "get", null);
63
+ Collection.Get()
64
+ ], MongoCollection.prototype, "get", null);
78
65
  __decorate([
79
- Collection.Update(),
80
- __metadata("design:type", Function),
81
- __metadata("design:paramtypes", [Object]),
82
- __metadata("design:returntype", Promise)
83
- ], MongoCollectionResource.prototype, "update", null);
66
+ Collection.Update()
67
+ ], MongoCollection.prototype, "update", null);
84
68
  __decorate([
85
- Collection.UpdateMany(),
86
- __metadata("design:type", Function),
87
- __metadata("design:paramtypes", [Object]),
88
- __metadata("design:returntype", Promise)
89
- ], MongoCollectionResource.prototype, "updateMany", null);
69
+ Collection.UpdateMany()
70
+ ], MongoCollection.prototype, "updateMany", null);
90
71
  __decorate([
91
- Collection.FindMany(),
92
- __metadata("design:type", Function),
93
- __metadata("design:paramtypes", [Object]),
94
- __metadata("design:returntype", Promise)
95
- ], MongoCollectionResource.prototype, "findMany", null);
72
+ Collection.FindMany()
73
+ ], MongoCollection.prototype, "findMany", null);
@@ -120,7 +120,7 @@ export class MongoEntityService {
120
120
  if (this.transformData)
121
121
  out = this.transformData(out);
122
122
  if (!out)
123
- throw new Error('"insertOne" operation returned no result!');
123
+ throw new Error('"insertOne" endpoint returned no result!');
124
124
  return out;
125
125
  }
126
126
  async updateOne(filter, doc, options) {
@@ -1,8 +1,7 @@
1
- import { __decorate, __metadata } from "tslib";
1
+ import { __decorate } from "tslib";
2
2
  import { Singleton } from '@opra/common';
3
- import { OperationContext } from '@opra/core';
4
3
  import { MongoAdapter } from './mongo-adapter.js';
5
- export class MongoSingletonResource {
4
+ export class MongoSingleton {
6
5
  constructor() {
7
6
  this.defaultLimit = 100;
8
7
  }
@@ -29,26 +28,14 @@ export class MongoSingletonResource {
29
28
  }
30
29
  }
31
30
  __decorate([
32
- Singleton.Create(),
33
- __metadata("design:type", Function),
34
- __metadata("design:paramtypes", [Object]),
35
- __metadata("design:returntype", Promise)
36
- ], MongoSingletonResource.prototype, "create", null);
31
+ Singleton.Create()
32
+ ], MongoSingleton.prototype, "create", null);
37
33
  __decorate([
38
- Singleton.Delete(),
39
- __metadata("design:type", Function),
40
- __metadata("design:paramtypes", [Object]),
41
- __metadata("design:returntype", Promise)
42
- ], MongoSingletonResource.prototype, "delete", null);
34
+ Singleton.Delete()
35
+ ], MongoSingleton.prototype, "delete", null);
43
36
  __decorate([
44
- Singleton.Get(),
45
- __metadata("design:type", Function),
46
- __metadata("design:paramtypes", [Object]),
47
- __metadata("design:returntype", Promise)
48
- ], MongoSingletonResource.prototype, "get", null);
37
+ Singleton.Get()
38
+ ], MongoSingleton.prototype, "get", null);
49
39
  __decorate([
50
- Singleton.Update(),
51
- __metadata("design:type", Function),
52
- __metadata("design:paramtypes", [Object]),
53
- __metadata("design:returntype", Promise)
54
- ], MongoSingletonResource.prototype, "update", null);
40
+ Singleton.Update()
41
+ ], MongoSingleton.prototype, "update", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/mongodb",
3
- "version": "0.23.2",
3
+ "version": "0.24.1",
4
4
  "description": "Opra MongoDB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  "ts-gems": "^2.4.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@opra/common": "^0.23.2",
37
- "@opra/core": "^0.23.2",
36
+ "@opra/common": "^0.24.1",
37
+ "@opra/core": "^0.24.1",
38
38
  "mongodb": ">=4.x.x"
39
39
  },
40
40
  "type": "module",
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './mongo-adapter.js';
2
- export * from './mongo-collection-resource.js';
2
+ export * from './mongo-collection.js';
3
3
  export * from './mongo-entity-service.js';
4
- export * from './mongo-singleton-resource.js';
4
+ export * from './mongo-singleton.js';
@@ -0,0 +1,22 @@
1
+ import mongodb from 'mongodb';
2
+ import { Maybe } from 'ts-gems';
3
+ import { Collection, ICollection, PartialOutput } from '@opra/common';
4
+ import { EndpointContext } from '@opra/core';
5
+ import { MongoEntityService } from './mongo-entity-service.js';
6
+ export declare namespace MongoCollection {
7
+ interface Options {
8
+ defaultLimit?: number;
9
+ }
10
+ }
11
+ export declare abstract class MongoCollection<T extends mongodb.Document> implements ICollection<T> {
12
+ defaultLimit?: number;
13
+ constructor(options?: MongoCollection.Options);
14
+ create?(ctx: Collection.Create.Context): Promise<PartialOutput<T>>;
15
+ delete?(ctx: EndpointContext): Promise<number>;
16
+ deleteMany?(ctx: EndpointContext): Promise<number>;
17
+ get?(ctx: EndpointContext): Promise<Maybe<PartialOutput<T>>>;
18
+ update?(ctx: EndpointContext): Promise<Maybe<PartialOutput<T>>>;
19
+ updateMany?(ctx: EndpointContext): Promise<number>;
20
+ findMany?(ctx: EndpointContext): Promise<PartialOutput<T>[]>;
21
+ abstract getService(ctx: EndpointContext): MongoEntityService<T> | Promise<MongoEntityService<T>>;
22
+ }
@@ -1,6 +1,6 @@
1
1
  import mongodb, { UpdateFilter } from 'mongodb';
2
2
  import { StrictOmit } from 'ts-gems';
3
- import { OperationContext, PartialOutput } from '@opra/core';
3
+ import { EndpointContext, PartialOutput } from '@opra/core';
4
4
  export declare namespace MongoEntityService {
5
5
  interface Options {
6
6
  db?: mongodb.Db;
@@ -9,7 +9,7 @@ export declare namespace MongoEntityService {
9
9
  }
10
10
  export declare class MongoEntityService<T extends mongodb.Document> {
11
11
  protected _collectionName: string;
12
- context: OperationContext;
12
+ context: EndpointContext;
13
13
  defaultLimit: number;
14
14
  db?: mongodb.Db;
15
15
  session?: mongodb.ClientSession;
@@ -23,7 +23,7 @@ export declare class MongoEntityService<T extends mongodb.Document> {
23
23
  insertOne(doc: mongodb.OptionalUnlessRequiredId<T>, options?: mongodb.InsertOneOptions): Promise<PartialOutput<T>>;
24
24
  updateOne(filter: mongodb.Filter<T>, doc: UpdateFilter<T> | Partial<T>, options?: mongodb.UpdateOptions): Promise<PartialOutput<T> | undefined>;
25
25
  updateMany(filter: mongodb.Filter<T>, doc: UpdateFilter<T> | Partial<T>, options?: StrictOmit<mongodb.UpdateOptions, 'upsert'>): Promise<number>;
26
- with(context: OperationContext, db?: mongodb.Db, session?: mongodb.ClientSession): MongoEntityService<T>;
26
+ with(context: EndpointContext, db?: mongodb.Db, session?: mongodb.ClientSession): MongoEntityService<T>;
27
27
  protected _onError(error: unknown): Promise<void>;
28
28
  protected getDatabase(): mongodb.Db | Promise<mongodb.Db>;
29
29
  protected getCollection(db: mongodb.Db): Promise<mongodb.Collection<T>>;
@@ -0,0 +1,13 @@
1
+ import mongodb from 'mongodb';
2
+ import { Maybe } from 'ts-gems';
3
+ import { PartialOutput } from '@opra/common';
4
+ import { EndpointContext } from '@opra/core';
5
+ import { MongoEntityService } from './mongo-entity-service.js';
6
+ export declare abstract class MongoSingleton<T extends mongodb.Document> {
7
+ defaultLimit: number;
8
+ create?(ctx: EndpointContext): Promise<PartialOutput<T>>;
9
+ delete?(ctx: EndpointContext): Promise<number>;
10
+ get?(ctx: EndpointContext): Promise<Maybe<PartialOutput<T>>>;
11
+ update?(ctx: EndpointContext): Promise<Maybe<PartialOutput<T>>>;
12
+ abstract getService(ctx: EndpointContext): MongoEntityService<T> | Promise<MongoEntityService<T>>;
13
+ }
@@ -1,22 +0,0 @@
1
- import mongodb from 'mongodb';
2
- import { Maybe } from 'ts-gems';
3
- import { Collection, CollectionResource, PartialOutput } from '@opra/common';
4
- import { OperationContext } from '@opra/core';
5
- import { MongoEntityService } from './mongo-entity-service.js';
6
- export declare namespace MongoCollectionResource {
7
- interface Options {
8
- defaultLimit?: number;
9
- }
10
- }
11
- export declare abstract class MongoCollectionResource<T extends mongodb.Document> implements CollectionResource<T> {
12
- defaultLimit?: number;
13
- constructor(options?: MongoCollectionResource.Options);
14
- create?(ctx: Collection.Create.Context): Promise<PartialOutput<T>>;
15
- delete?(ctx: OperationContext): Promise<number>;
16
- deleteMany?(ctx: OperationContext): Promise<number>;
17
- get?(ctx: OperationContext): Promise<Maybe<PartialOutput<T>>>;
18
- update?(ctx: OperationContext): Promise<Maybe<PartialOutput<T>>>;
19
- updateMany?(ctx: OperationContext): Promise<number>;
20
- findMany?(ctx: OperationContext): Promise<PartialOutput<T>[]>;
21
- abstract getService(ctx: OperationContext): MongoEntityService<T> | Promise<MongoEntityService<T>>;
22
- }
@@ -1,13 +0,0 @@
1
- import mongodb from 'mongodb';
2
- import { Maybe } from 'ts-gems';
3
- import { PartialOutput } from '@opra/common';
4
- import { OperationContext } from '@opra/core';
5
- import { MongoEntityService } from './mongo-entity-service.js';
6
- export declare abstract class MongoSingletonResource<T extends mongodb.Document> {
7
- defaultLimit: number;
8
- create?(ctx: OperationContext): Promise<PartialOutput<T>>;
9
- delete?(ctx: OperationContext): Promise<number>;
10
- get?(ctx: OperationContext): Promise<Maybe<PartialOutput<T>>>;
11
- update?(ctx: OperationContext): Promise<Maybe<PartialOutput<T>>>;
12
- abstract getService(ctx: OperationContext): MongoEntityService<T> | Promise<MongoEntityService<T>>;
13
- }