@prisma-next/mongo-wire 0.4.0-dev.9 → 0.4.2
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/index.d.mts +14 -27
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +18 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/results.ts +15 -26
- package/src/wire-commands.ts +30 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
+
import { DeleteManyResult, DeleteOneResult, InsertManyResult, InsertOneResult, UpdateManyResult, UpdateOneResult } from "@prisma-next/mongo-query-ast/execution";
|
|
1
2
|
import { Document, RawPipeline } from "@prisma-next/mongo-value";
|
|
2
3
|
|
|
3
|
-
//#region src/results.d.ts
|
|
4
|
-
interface InsertOneResult {
|
|
5
|
-
readonly insertedId: unknown;
|
|
6
|
-
}
|
|
7
|
-
interface InsertManyResult {
|
|
8
|
-
readonly insertedIds: ReadonlyArray<unknown>;
|
|
9
|
-
readonly insertedCount: number;
|
|
10
|
-
}
|
|
11
|
-
interface UpdateOneResult {
|
|
12
|
-
readonly matchedCount: number;
|
|
13
|
-
readonly modifiedCount: number;
|
|
14
|
-
}
|
|
15
|
-
interface UpdateManyResult {
|
|
16
|
-
readonly matchedCount: number;
|
|
17
|
-
readonly modifiedCount: number;
|
|
18
|
-
}
|
|
19
|
-
interface DeleteOneResult {
|
|
20
|
-
readonly deletedCount: number;
|
|
21
|
-
}
|
|
22
|
-
interface DeleteManyResult {
|
|
23
|
-
readonly deletedCount: number;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
4
|
//#region src/wire-commands.d.ts
|
|
27
5
|
declare abstract class MongoWireCommand {
|
|
28
6
|
abstract readonly kind: string;
|
|
@@ -39,7 +17,8 @@ declare class UpdateOneWireCommand extends MongoWireCommand {
|
|
|
39
17
|
readonly kind: "updateOne";
|
|
40
18
|
readonly filter: Document;
|
|
41
19
|
readonly update: Document | ReadonlyArray<Document>;
|
|
42
|
-
|
|
20
|
+
readonly upsert: boolean;
|
|
21
|
+
constructor(collection: string, filter: Document, update: Document | ReadonlyArray<Document>, upsert?: boolean);
|
|
43
22
|
}
|
|
44
23
|
declare class DeleteOneWireCommand extends MongoWireCommand {
|
|
45
24
|
readonly kind: "deleteOne";
|
|
@@ -55,7 +34,8 @@ declare class UpdateManyWireCommand extends MongoWireCommand {
|
|
|
55
34
|
readonly kind: "updateMany";
|
|
56
35
|
readonly filter: Document;
|
|
57
36
|
readonly update: Document | ReadonlyArray<Document>;
|
|
58
|
-
|
|
37
|
+
readonly upsert: boolean;
|
|
38
|
+
constructor(collection: string, filter: Document, update: Document | ReadonlyArray<Document>, upsert?: boolean);
|
|
59
39
|
}
|
|
60
40
|
declare class DeleteManyWireCommand extends MongoWireCommand {
|
|
61
41
|
readonly kind: "deleteMany";
|
|
@@ -67,12 +47,19 @@ declare class FindOneAndUpdateWireCommand extends MongoWireCommand {
|
|
|
67
47
|
readonly filter: Document;
|
|
68
48
|
readonly update: Document | ReadonlyArray<Document>;
|
|
69
49
|
readonly upsert: boolean;
|
|
70
|
-
|
|
50
|
+
readonly sort: Record<string, 1 | -1> | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* When `undefined`, the option is omitted from the underlying driver
|
|
53
|
+
* call so Mongo's documented default (pre-image document) applies.
|
|
54
|
+
*/
|
|
55
|
+
readonly returnDocument: 'before' | 'after' | undefined;
|
|
56
|
+
constructor(collection: string, filter: Document, update: Document | ReadonlyArray<Document>, upsert?: boolean, sort?: Record<string, 1 | -1>, returnDocument?: 'before' | 'after');
|
|
71
57
|
}
|
|
72
58
|
declare class FindOneAndDeleteWireCommand extends MongoWireCommand {
|
|
73
59
|
readonly kind: "findOneAndDelete";
|
|
74
60
|
readonly filter: Document;
|
|
75
|
-
|
|
61
|
+
readonly sort: Record<string, 1 | -1> | undefined;
|
|
62
|
+
constructor(collection: string, filter: Document, sort?: Record<string, 1 | -1>);
|
|
76
63
|
}
|
|
77
64
|
declare class AggregateWireCommand extends MongoWireCommand {
|
|
78
65
|
readonly kind: "aggregate";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/wire-commands.ts"],"sourcesContent":[],"mappings":";;;;uBAEe,gBAAA;;;EAAA,UAAA,WAAgB,CAAA,UAAA,EAAA,MAAA;EAalB,UAAA,MAAA,CAAA,CAAA,EAAA,IAAqB;;AAIU,cAJ/B,oBAAA,SAA6B,gBAAA,CAIE;EAJF,SAAA,IAAA,EAAA,WAAA;EAAgB,SAAA,QAAA,EAErC,QAFqC;EAW7C,WAAA,CAAA,UAAA,EAAqB,MAAA,EAAA,QAAA,EAPU,QAOV;;AAGf,cAHN,oBAAA,SAA6B,gBAAA,CAGvB;EAAyB,SAAA,IAAA,EAAA,WAAA;EAAd,SAAA,MAAA,EADX,QACW;EAKlB,SAAA,MAAA,EALO,QAKP,GALkB,aAKlB,CALgC,QAKhC,CAAA;EACA,SAAA,MAAA,EAAA,OAAA;EAAyB,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,MAAA,EADzB,QACyB,EAAA,MAAA,EAAzB,QAAyB,GAAd,aAAc,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;AATK,cAoB7B,oBAAA,SAA6B,gBAAA,CApBA;EAAgB,SAAA,IAAA,EAAA,WAAA;EAoB7C,SAAA,MAAA,EAEM,QAFe;EAEf,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,MAAA,EAEuB,QAFvB;;AAFuB,cAW7B,qBAAA,SAA8B,gBAAA,CAXD;EAAgB,SAAA,IAAA,EAAA,YAAA;EAW7C,SAAA,SAAA,EAES,aAFa,CAEC,QAFD,CAAA;EAEC,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,SAAA,EAES,aAFT,CAEuB,QAFv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,IAAA,EAAA,kBAAA;EACA,SAAA,MAAA,EAiBO,QAjBP;EAAyB,SAAA,IAAA,EAkBpB,MAlBoB,CAAA,MAAA,EAAA,CAAA,GAAA,CAAA,CAAA,CAAA,GAAA,SAAA;EAAd,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,MAAA,EAoBmB,QApBnB,EAAA,IAAA,CAAA,EAoBoC,MApBpC,CAAA,MAAA,EAAA,CAAA,GAAA,CAAA,CAAA,CAAA;;AAf0B,cA2CpC,oBAAA,SAA6B,gBAAA,CA3CO;EAAgB,SAAA,IAAA,EAAA,WAAA;EA8BpD,SAAA,QAAA,EAeQ,WAfoB;EAEtB,WAAA,CAAA,UAAA,EAAA,MAAA,EAAA,QAAA,EAeyB,WAfzB;;AAGuB,KAmB9B,mBAAA,GACR,oBApBsC,GAqBtC,qBArBsC,GAsBtC,oBAtBsC,GAuBtC,qBAvBsC,GAwBtC,oBAxBsC,GAyBtC,qBAzBsC,GA0BtC,2BA1BsC,GA2BtC,2BA3BsC,GA4BtC,oBA5BsC"}
|
package/dist/index.mjs
CHANGED
|
@@ -21,10 +21,12 @@ var UpdateOneWireCommand = class extends MongoWireCommand {
|
|
|
21
21
|
kind = "updateOne";
|
|
22
22
|
filter;
|
|
23
23
|
update;
|
|
24
|
-
|
|
24
|
+
upsert;
|
|
25
|
+
constructor(collection, filter, update, upsert = false) {
|
|
25
26
|
super(collection);
|
|
26
27
|
this.filter = filter;
|
|
27
28
|
this.update = update;
|
|
29
|
+
this.upsert = upsert;
|
|
28
30
|
this.freeze();
|
|
29
31
|
}
|
|
30
32
|
};
|
|
@@ -50,10 +52,12 @@ var UpdateManyWireCommand = class extends MongoWireCommand {
|
|
|
50
52
|
kind = "updateMany";
|
|
51
53
|
filter;
|
|
52
54
|
update;
|
|
53
|
-
|
|
55
|
+
upsert;
|
|
56
|
+
constructor(collection, filter, update, upsert = false) {
|
|
54
57
|
super(collection);
|
|
55
58
|
this.filter = filter;
|
|
56
59
|
this.update = update;
|
|
60
|
+
this.upsert = upsert;
|
|
57
61
|
this.freeze();
|
|
58
62
|
}
|
|
59
63
|
};
|
|
@@ -71,20 +75,30 @@ var FindOneAndUpdateWireCommand = class extends MongoWireCommand {
|
|
|
71
75
|
filter;
|
|
72
76
|
update;
|
|
73
77
|
upsert;
|
|
74
|
-
|
|
78
|
+
sort;
|
|
79
|
+
/**
|
|
80
|
+
* When `undefined`, the option is omitted from the underlying driver
|
|
81
|
+
* call so Mongo's documented default (pre-image document) applies.
|
|
82
|
+
*/
|
|
83
|
+
returnDocument;
|
|
84
|
+
constructor(collection, filter, update, upsert = false, sort, returnDocument) {
|
|
75
85
|
super(collection);
|
|
76
86
|
this.filter = filter;
|
|
77
87
|
this.update = update;
|
|
78
88
|
this.upsert = upsert;
|
|
89
|
+
this.sort = sort;
|
|
90
|
+
this.returnDocument = returnDocument;
|
|
79
91
|
this.freeze();
|
|
80
92
|
}
|
|
81
93
|
};
|
|
82
94
|
var FindOneAndDeleteWireCommand = class extends MongoWireCommand {
|
|
83
95
|
kind = "findOneAndDelete";
|
|
84
96
|
filter;
|
|
85
|
-
|
|
97
|
+
sort;
|
|
98
|
+
constructor(collection, filter, sort) {
|
|
86
99
|
super(collection);
|
|
87
100
|
this.filter = filter;
|
|
101
|
+
this.sort = sort;
|
|
88
102
|
this.freeze();
|
|
89
103
|
}
|
|
90
104
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/wire-commands.ts"],"sourcesContent":["import type { Document, RawPipeline } from '@prisma-next/mongo-value';\n\nabstract class MongoWireCommand {\n abstract readonly kind: string;\n readonly collection: string;\n\n protected constructor(collection: string) {\n this.collection = collection;\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\nexport class InsertOneWireCommand extends MongoWireCommand {\n readonly kind = 'insertOne' as const;\n readonly document: Document;\n\n constructor(collection: string, document: Document) {\n super(collection);\n this.document = document;\n this.freeze();\n }\n}\n\nexport class UpdateOneWireCommand extends MongoWireCommand {\n readonly kind = 'updateOne' as const;\n readonly filter: Document;\n readonly update: Document | ReadonlyArray<Document>;\n\n constructor(collection: string
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/wire-commands.ts"],"sourcesContent":["import type { Document, RawPipeline } from '@prisma-next/mongo-value';\n\nabstract class MongoWireCommand {\n abstract readonly kind: string;\n readonly collection: string;\n\n protected constructor(collection: string) {\n this.collection = collection;\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\nexport class InsertOneWireCommand extends MongoWireCommand {\n readonly kind = 'insertOne' as const;\n readonly document: Document;\n\n constructor(collection: string, document: Document) {\n super(collection);\n this.document = document;\n this.freeze();\n }\n}\n\nexport class UpdateOneWireCommand extends MongoWireCommand {\n readonly kind = 'updateOne' as const;\n readonly filter: Document;\n readonly update: Document | ReadonlyArray<Document>;\n readonly upsert: boolean;\n\n constructor(\n collection: string,\n filter: Document,\n update: Document | ReadonlyArray<Document>,\n upsert = false,\n ) {\n super(collection);\n this.filter = filter;\n this.update = update;\n this.upsert = upsert;\n this.freeze();\n }\n}\n\nexport class DeleteOneWireCommand extends MongoWireCommand {\n readonly kind = 'deleteOne' as const;\n readonly filter: Document;\n\n constructor(collection: string, filter: Document) {\n super(collection);\n this.filter = filter;\n this.freeze();\n }\n}\n\nexport class InsertManyWireCommand extends MongoWireCommand {\n readonly kind = 'insertMany' as const;\n readonly documents: ReadonlyArray<Document>;\n\n constructor(collection: string, documents: ReadonlyArray<Document>) {\n super(collection);\n this.documents = documents;\n this.freeze();\n }\n}\n\nexport class UpdateManyWireCommand extends MongoWireCommand {\n readonly kind = 'updateMany' as const;\n readonly filter: Document;\n readonly update: Document | ReadonlyArray<Document>;\n readonly upsert: boolean;\n\n constructor(\n collection: string,\n filter: Document,\n update: Document | ReadonlyArray<Document>,\n upsert = false,\n ) {\n super(collection);\n this.filter = filter;\n this.update = update;\n this.upsert = upsert;\n this.freeze();\n }\n}\n\nexport class DeleteManyWireCommand extends MongoWireCommand {\n readonly kind = 'deleteMany' as const;\n readonly filter: Document;\n\n constructor(collection: string, filter: Document) {\n super(collection);\n this.filter = filter;\n this.freeze();\n }\n}\n\nexport class FindOneAndUpdateWireCommand extends MongoWireCommand {\n readonly kind = 'findOneAndUpdate' as const;\n readonly filter: Document;\n readonly update: Document | ReadonlyArray<Document>;\n readonly upsert: boolean;\n readonly sort: Record<string, 1 | -1> | undefined;\n /**\n * When `undefined`, the option is omitted from the underlying driver\n * call so Mongo's documented default (pre-image document) applies.\n */\n readonly returnDocument: 'before' | 'after' | undefined;\n\n constructor(\n collection: string,\n filter: Document,\n update: Document | ReadonlyArray<Document>,\n upsert = false,\n sort?: Record<string, 1 | -1>,\n returnDocument?: 'before' | 'after',\n ) {\n super(collection);\n this.filter = filter;\n this.update = update;\n this.upsert = upsert;\n this.sort = sort;\n this.returnDocument = returnDocument;\n this.freeze();\n }\n}\n\nexport class FindOneAndDeleteWireCommand extends MongoWireCommand {\n readonly kind = 'findOneAndDelete' as const;\n readonly filter: Document;\n readonly sort: Record<string, 1 | -1> | undefined;\n\n constructor(collection: string, filter: Document, sort?: Record<string, 1 | -1>) {\n super(collection);\n this.filter = filter;\n this.sort = sort;\n this.freeze();\n }\n}\n\nexport class AggregateWireCommand extends MongoWireCommand {\n readonly kind = 'aggregate' as const;\n readonly pipeline: RawPipeline;\n\n constructor(collection: string, pipeline: RawPipeline) {\n super(collection);\n this.pipeline = pipeline;\n this.freeze();\n }\n}\n\nexport type AnyMongoWireCommand =\n | InsertOneWireCommand\n | InsertManyWireCommand\n | UpdateOneWireCommand\n | UpdateManyWireCommand\n | DeleteOneWireCommand\n | DeleteManyWireCommand\n | FindOneAndUpdateWireCommand\n | FindOneAndDeleteWireCommand\n | AggregateWireCommand;\n"],"mappings":";AAEA,IAAe,mBAAf,MAAgC;CAE9B,AAAS;CAET,AAAU,YAAY,YAAoB;AACxC,OAAK,aAAa;;CAGpB,AAAU,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AACjB,OAAK,SAAS;AACd,OAAK,SAAS;AACd,OAAK,SAAS;AACd,OAAK,OAAO;AACZ,OAAK,iBAAiB;AACtB,OAAK,QAAQ;;;AAIjB,IAAa,8BAAb,cAAiD,iBAAiB;CAChE,AAAS,OAAO;CAChB,AAAS;CACT,AAAS;CAET,YAAY,YAAoB,QAAkB,MAA+B;AAC/E,QAAM,WAAW;AACjB,OAAK,SAAS;AACd,OAAK,OAAO;AACZ,OAAK,QAAQ;;;AAIjB,IAAa,uBAAb,cAA0C,iBAAiB;CACzD,AAAS,OAAO;CAChB,AAAS;CAET,YAAY,YAAoB,UAAuB;AACrD,QAAM,WAAW;AACjB,OAAK,WAAW;AAChB,OAAK,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo-wire",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Wire command types and result types for Prisma Next MongoDB support",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/mongo-value": "0.4.
|
|
8
|
+
"@prisma-next/mongo-value": "0.4.2",
|
|
9
|
+
"@prisma-next/mongo-query-ast": "0.4.2"
|
|
9
10
|
},
|
|
10
11
|
"devDependencies": {
|
|
11
12
|
"tsdown": "0.18.4",
|
package/src/results.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly matchedCount: number;
|
|
17
|
-
readonly modifiedCount: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface DeleteOneResult {
|
|
21
|
-
readonly deletedCount: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface DeleteManyResult {
|
|
25
|
-
readonly deletedCount: number;
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Re-export canonical command result types from the query layer.
|
|
3
|
+
*
|
|
4
|
+
* The result shape definitions live in `@prisma-next/mongo-query-ast`
|
|
5
|
+
* because they are part of the primitive language — the transport layer
|
|
6
|
+
* satisfies those interfaces, it does not define them.
|
|
7
|
+
*/
|
|
8
|
+
export type {
|
|
9
|
+
DeleteManyResult,
|
|
10
|
+
DeleteOneResult,
|
|
11
|
+
InsertManyResult,
|
|
12
|
+
InsertOneResult,
|
|
13
|
+
UpdateManyResult,
|
|
14
|
+
UpdateOneResult,
|
|
15
|
+
} from '@prisma-next/mongo-query-ast/execution';
|
package/src/wire-commands.ts
CHANGED
|
@@ -28,11 +28,18 @@ export class UpdateOneWireCommand extends MongoWireCommand {
|
|
|
28
28
|
readonly kind = 'updateOne' as const;
|
|
29
29
|
readonly filter: Document;
|
|
30
30
|
readonly update: Document | ReadonlyArray<Document>;
|
|
31
|
+
readonly upsert: boolean;
|
|
31
32
|
|
|
32
|
-
constructor(
|
|
33
|
+
constructor(
|
|
34
|
+
collection: string,
|
|
35
|
+
filter: Document,
|
|
36
|
+
update: Document | ReadonlyArray<Document>,
|
|
37
|
+
upsert = false,
|
|
38
|
+
) {
|
|
33
39
|
super(collection);
|
|
34
40
|
this.filter = filter;
|
|
35
41
|
this.update = update;
|
|
42
|
+
this.upsert = upsert;
|
|
36
43
|
this.freeze();
|
|
37
44
|
}
|
|
38
45
|
}
|
|
@@ -63,11 +70,18 @@ export class UpdateManyWireCommand extends MongoWireCommand {
|
|
|
63
70
|
readonly kind = 'updateMany' as const;
|
|
64
71
|
readonly filter: Document;
|
|
65
72
|
readonly update: Document | ReadonlyArray<Document>;
|
|
73
|
+
readonly upsert: boolean;
|
|
66
74
|
|
|
67
|
-
constructor(
|
|
75
|
+
constructor(
|
|
76
|
+
collection: string,
|
|
77
|
+
filter: Document,
|
|
78
|
+
update: Document | ReadonlyArray<Document>,
|
|
79
|
+
upsert = false,
|
|
80
|
+
) {
|
|
68
81
|
super(collection);
|
|
69
82
|
this.filter = filter;
|
|
70
83
|
this.update = update;
|
|
84
|
+
this.upsert = upsert;
|
|
71
85
|
this.freeze();
|
|
72
86
|
}
|
|
73
87
|
}
|
|
@@ -88,17 +102,27 @@ export class FindOneAndUpdateWireCommand extends MongoWireCommand {
|
|
|
88
102
|
readonly filter: Document;
|
|
89
103
|
readonly update: Document | ReadonlyArray<Document>;
|
|
90
104
|
readonly upsert: boolean;
|
|
105
|
+
readonly sort: Record<string, 1 | -1> | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* When `undefined`, the option is omitted from the underlying driver
|
|
108
|
+
* call so Mongo's documented default (pre-image document) applies.
|
|
109
|
+
*/
|
|
110
|
+
readonly returnDocument: 'before' | 'after' | undefined;
|
|
91
111
|
|
|
92
112
|
constructor(
|
|
93
113
|
collection: string,
|
|
94
114
|
filter: Document,
|
|
95
115
|
update: Document | ReadonlyArray<Document>,
|
|
96
|
-
upsert
|
|
116
|
+
upsert = false,
|
|
117
|
+
sort?: Record<string, 1 | -1>,
|
|
118
|
+
returnDocument?: 'before' | 'after',
|
|
97
119
|
) {
|
|
98
120
|
super(collection);
|
|
99
121
|
this.filter = filter;
|
|
100
122
|
this.update = update;
|
|
101
123
|
this.upsert = upsert;
|
|
124
|
+
this.sort = sort;
|
|
125
|
+
this.returnDocument = returnDocument;
|
|
102
126
|
this.freeze();
|
|
103
127
|
}
|
|
104
128
|
}
|
|
@@ -106,10 +130,12 @@ export class FindOneAndUpdateWireCommand extends MongoWireCommand {
|
|
|
106
130
|
export class FindOneAndDeleteWireCommand extends MongoWireCommand {
|
|
107
131
|
readonly kind = 'findOneAndDelete' as const;
|
|
108
132
|
readonly filter: Document;
|
|
133
|
+
readonly sort: Record<string, 1 | -1> | undefined;
|
|
109
134
|
|
|
110
|
-
constructor(collection: string, filter: Document) {
|
|
135
|
+
constructor(collection: string, filter: Document, sort?: Record<string, 1 | -1>) {
|
|
111
136
|
super(collection);
|
|
112
137
|
this.filter = filter;
|
|
138
|
+
this.sort = sort;
|
|
113
139
|
this.freeze();
|
|
114
140
|
}
|
|
115
141
|
}
|