@event-driven-io/pongo 0.16.4-alpha.1 → 0.16.4
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/chunk-HZVM5GBH.cjs +1160 -0
- package/dist/chunk-HZVM5GBH.cjs.map +1 -0
- package/dist/chunk-IXL27BW5.js +1160 -0
- package/dist/{chunk-CYDDN3CZ.js.map → chunk-IXL27BW5.js.map} +1 -1
- package/dist/cli.cjs +436 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +436 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +78 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +78 -1
- package/dist/shim.cjs +332 -1
- package/dist/shim.cjs.map +1 -1
- package/dist/shim.js +332 -1
- package/dist/shim.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-CYDDN3CZ.js +0 -76
- package/dist/chunk-PUUNCOTH.cjs +0 -76
- package/dist/chunk-PUUNCOTH.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,79 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
var _chunkHZVM5GBHcjs = require('./chunk-HZVM5GBH.cjs');
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
exports.ConcurrencyError = _chunkHZVM5GBHcjs.ConcurrencyError; exports.DOCUMENT_DOES_NOT_EXIST = _chunkHZVM5GBHcjs.DOCUMENT_DOES_NOT_EXIST; exports.DOCUMENT_EXISTS = _chunkHZVM5GBHcjs.DOCUMENT_EXISTS; exports.NO_CONCURRENCY_CHECK = _chunkHZVM5GBHcjs.NO_CONCURRENCY_CHECK; exports.ObjectId = _chunkHZVM5GBHcjs.ObjectId; exports.OperatorMap = _chunkHZVM5GBHcjs.OperatorMap; exports.PongoError = _chunkHZVM5GBHcjs.PongoError; exports.QueryOperators = _chunkHZVM5GBHcjs.QueryOperators; exports.clientToDbOptions = _chunkHZVM5GBHcjs.clientToDbOptions; exports.deepEquals = _chunkHZVM5GBHcjs.deepEquals; exports.expectedVersion = _chunkHZVM5GBHcjs.expectedVersion; exports.expectedVersionValue = _chunkHZVM5GBHcjs.expectedVersionValue; exports.getPongoDb = _chunkHZVM5GBHcjs.getPongoDb; exports.hasOperators = _chunkHZVM5GBHcjs.hasOperators; exports.isEquatable = _chunkHZVM5GBHcjs.isEquatable; exports.isGeneralExpectedDocumentVersion = _chunkHZVM5GBHcjs.isGeneralExpectedDocumentVersion; exports.isNumber = _chunkHZVM5GBHcjs.isNumber; exports.isOperator = _chunkHZVM5GBHcjs.isOperator; exports.isPostgresClientOptions = _chunkHZVM5GBHcjs.isPostgresClientOptions; exports.isString = _chunkHZVM5GBHcjs.isString; exports.objectEntries = _chunkHZVM5GBHcjs.objectEntries; exports.operationResult = _chunkHZVM5GBHcjs.operationResult; exports.pongoClient = _chunkHZVM5GBHcjs.pongoClient; exports.pongoCollection = _chunkHZVM5GBHcjs.pongoCollection; exports.pongoCollectionPostgreSQLMigrations = _chunkHZVM5GBHcjs.pongoCollectionPostgreSQLMigrations; exports.pongoCollectionSchemaComponent = _chunkHZVM5GBHcjs.pongoCollectionSchemaComponent; exports.pongoDbSchemaComponent = _chunkHZVM5GBHcjs.pongoDbSchemaComponent; exports.pongoSchema = _chunkHZVM5GBHcjs.pongoSchema; exports.pongoSession = _chunkHZVM5GBHcjs.pongoSession; exports.pongoTransaction = _chunkHZVM5GBHcjs.pongoTransaction; exports.postgresDb = _chunkHZVM5GBHcjs.postgresDb; exports.postgresSQLBuilder = _chunkHZVM5GBHcjs.postgresSQLBuilder; exports.proxyClientWithSchema = _chunkHZVM5GBHcjs.proxyClientWithSchema; exports.proxyPongoDbWithSchema = _chunkHZVM5GBHcjs.proxyPongoDbWithSchema; exports.toClientSchemaMetadata = _chunkHZVM5GBHcjs.toClientSchemaMetadata; exports.toDbSchemaMetadata = _chunkHZVM5GBHcjs.toDbSchemaMetadata; exports.transactionExecutorOrDefault = _chunkHZVM5GBHcjs.transactionExecutorOrDefault;
|
|
2
79
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/index.cjs"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,k0EAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/index.cjs"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,79 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
ConcurrencyError,
|
|
3
|
+
DOCUMENT_DOES_NOT_EXIST,
|
|
4
|
+
DOCUMENT_EXISTS,
|
|
5
|
+
NO_CONCURRENCY_CHECK,
|
|
6
|
+
ObjectId,
|
|
7
|
+
OperatorMap,
|
|
8
|
+
PongoError,
|
|
9
|
+
QueryOperators,
|
|
10
|
+
clientToDbOptions,
|
|
11
|
+
deepEquals,
|
|
12
|
+
expectedVersion,
|
|
13
|
+
expectedVersionValue,
|
|
14
|
+
getPongoDb,
|
|
15
|
+
hasOperators,
|
|
16
|
+
isEquatable,
|
|
17
|
+
isGeneralExpectedDocumentVersion,
|
|
18
|
+
isNumber,
|
|
19
|
+
isOperator,
|
|
20
|
+
isPostgresClientOptions,
|
|
21
|
+
isString,
|
|
22
|
+
objectEntries,
|
|
23
|
+
operationResult,
|
|
24
|
+
pongoClient,
|
|
25
|
+
pongoCollection,
|
|
26
|
+
pongoCollectionPostgreSQLMigrations,
|
|
27
|
+
pongoCollectionSchemaComponent,
|
|
28
|
+
pongoDbSchemaComponent,
|
|
29
|
+
pongoSchema,
|
|
30
|
+
pongoSession,
|
|
31
|
+
pongoTransaction,
|
|
32
|
+
postgresDb,
|
|
33
|
+
postgresSQLBuilder,
|
|
34
|
+
proxyClientWithSchema,
|
|
35
|
+
proxyPongoDbWithSchema,
|
|
36
|
+
toClientSchemaMetadata,
|
|
37
|
+
toDbSchemaMetadata,
|
|
38
|
+
transactionExecutorOrDefault
|
|
39
|
+
} from "./chunk-IXL27BW5.js";
|
|
40
|
+
export {
|
|
41
|
+
ConcurrencyError,
|
|
42
|
+
DOCUMENT_DOES_NOT_EXIST,
|
|
43
|
+
DOCUMENT_EXISTS,
|
|
44
|
+
NO_CONCURRENCY_CHECK,
|
|
45
|
+
ObjectId,
|
|
46
|
+
OperatorMap,
|
|
47
|
+
PongoError,
|
|
48
|
+
QueryOperators,
|
|
49
|
+
clientToDbOptions,
|
|
50
|
+
deepEquals,
|
|
51
|
+
expectedVersion,
|
|
52
|
+
expectedVersionValue,
|
|
53
|
+
getPongoDb,
|
|
54
|
+
hasOperators,
|
|
55
|
+
isEquatable,
|
|
56
|
+
isGeneralExpectedDocumentVersion,
|
|
57
|
+
isNumber,
|
|
58
|
+
isOperator,
|
|
59
|
+
isPostgresClientOptions,
|
|
60
|
+
isString,
|
|
61
|
+
objectEntries,
|
|
62
|
+
operationResult,
|
|
63
|
+
pongoClient,
|
|
64
|
+
pongoCollection,
|
|
65
|
+
pongoCollectionPostgreSQLMigrations,
|
|
66
|
+
pongoCollectionSchemaComponent,
|
|
67
|
+
pongoDbSchemaComponent,
|
|
68
|
+
pongoSchema,
|
|
69
|
+
pongoSession,
|
|
70
|
+
pongoTransaction,
|
|
71
|
+
postgresDb,
|
|
72
|
+
postgresSQLBuilder,
|
|
73
|
+
proxyClientWithSchema,
|
|
74
|
+
proxyPongoDbWithSchema,
|
|
75
|
+
toClientSchemaMetadata,
|
|
76
|
+
toDbSchemaMetadata,
|
|
77
|
+
transactionExecutorOrDefault
|
|
78
|
+
};
|
|
2
79
|
//# sourceMappingURL=index.js.map
|
package/dist/shim.cjs
CHANGED
|
@@ -1,2 +1,333 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkHZVM5GBHcjs = require('./chunk-HZVM5GBH.cjs');
|
|
5
|
+
|
|
6
|
+
// src/mongo/findCursor.ts
|
|
7
|
+
var FindCursor = (_class = class {
|
|
8
|
+
|
|
9
|
+
__init() {this.documents = null}
|
|
10
|
+
__init2() {this.index = 0}
|
|
11
|
+
constructor(documents) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
12
|
+
this.findDocumentsPromise = documents;
|
|
13
|
+
}
|
|
14
|
+
async toArray() {
|
|
15
|
+
return this.findDocuments();
|
|
16
|
+
}
|
|
17
|
+
async forEach(callback) {
|
|
18
|
+
const docs = await this.findDocuments();
|
|
19
|
+
for (const doc of docs) {
|
|
20
|
+
callback(doc);
|
|
21
|
+
}
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
}
|
|
24
|
+
hasNext() {
|
|
25
|
+
if (this.documents === null) throw Error("Error while fetching documents");
|
|
26
|
+
return this.index < this.documents.length;
|
|
27
|
+
}
|
|
28
|
+
async next() {
|
|
29
|
+
const docs = await this.findDocuments();
|
|
30
|
+
return this.hasNext() ? _nullishCoalesce(docs[this.index++], () => ( null)) : null;
|
|
31
|
+
}
|
|
32
|
+
async findDocuments() {
|
|
33
|
+
this.documents = await this.findDocumentsPromise;
|
|
34
|
+
return this.documents;
|
|
35
|
+
}
|
|
36
|
+
}, _class);
|
|
37
|
+
|
|
38
|
+
// src/mongo/mongoDb.ts
|
|
39
|
+
require('mongodb');
|
|
40
|
+
|
|
41
|
+
// src/mongo/mongoCollection.ts
|
|
42
|
+
var toCollectionOperationOptions = (options) => _optionalChain([options, 'optionalAccess', _ => _.session]) ? { session: options.session } : void 0;
|
|
43
|
+
var Collection = class {
|
|
44
|
+
|
|
45
|
+
constructor(collection) {
|
|
46
|
+
this.collection = collection;
|
|
47
|
+
}
|
|
48
|
+
get dbName() {
|
|
49
|
+
return this.collection.dbName;
|
|
50
|
+
}
|
|
51
|
+
get collectionName() {
|
|
52
|
+
return this.collection.collectionName;
|
|
53
|
+
}
|
|
54
|
+
get namespace() {
|
|
55
|
+
return `${this.dbName}.${this.collectionName}`;
|
|
56
|
+
}
|
|
57
|
+
get readConcern() {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
get readPreference() {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
get bsonOptions() {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
get writeConcern() {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
get hint() {
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
set hint(v) {
|
|
73
|
+
throw new Error("Method not implemented.");
|
|
74
|
+
}
|
|
75
|
+
async insertOne(doc, options) {
|
|
76
|
+
const result = await this.collection.insertOne(
|
|
77
|
+
doc,
|
|
78
|
+
toCollectionOperationOptions(options)
|
|
79
|
+
);
|
|
80
|
+
return {
|
|
81
|
+
acknowledged: result.acknowledged,
|
|
82
|
+
insertedId: result.insertedId
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async insertMany(docs, options) {
|
|
86
|
+
const result = await this.collection.insertMany(
|
|
87
|
+
docs,
|
|
88
|
+
toCollectionOperationOptions(options)
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
acknowledged: result.acknowledged,
|
|
92
|
+
insertedIds: result.insertedIds,
|
|
93
|
+
insertedCount: result.insertedCount
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
bulkWrite(_operations, _options) {
|
|
97
|
+
throw new Error("Method not implemented.");
|
|
98
|
+
}
|
|
99
|
+
async updateOne(filter, update, options) {
|
|
100
|
+
const result = await this.collection.updateOne(
|
|
101
|
+
filter,
|
|
102
|
+
update,
|
|
103
|
+
toCollectionOperationOptions(options)
|
|
104
|
+
);
|
|
105
|
+
return {
|
|
106
|
+
acknowledged: result.acknowledged,
|
|
107
|
+
matchedCount: result.modifiedCount,
|
|
108
|
+
modifiedCount: result.modifiedCount,
|
|
109
|
+
upsertedCount: result.modifiedCount,
|
|
110
|
+
upsertedId: null
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
replaceOne(filter, document, options) {
|
|
114
|
+
return this.collection.replaceOne(
|
|
115
|
+
filter,
|
|
116
|
+
document,
|
|
117
|
+
toCollectionOperationOptions(options)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
async updateMany(filter, update, options) {
|
|
121
|
+
const result = await this.collection.updateMany(
|
|
122
|
+
filter,
|
|
123
|
+
update,
|
|
124
|
+
toCollectionOperationOptions(options)
|
|
125
|
+
);
|
|
126
|
+
return {
|
|
127
|
+
acknowledged: result.acknowledged,
|
|
128
|
+
matchedCount: result.modifiedCount,
|
|
129
|
+
modifiedCount: result.modifiedCount,
|
|
130
|
+
upsertedCount: result.modifiedCount,
|
|
131
|
+
upsertedId: null
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async deleteOne(filter, options) {
|
|
135
|
+
const result = await this.collection.deleteOne(
|
|
136
|
+
filter,
|
|
137
|
+
toCollectionOperationOptions(options)
|
|
138
|
+
);
|
|
139
|
+
return {
|
|
140
|
+
acknowledged: result.acknowledged,
|
|
141
|
+
deletedCount: result.deletedCount
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async deleteMany(filter, options) {
|
|
145
|
+
const result = await this.collection.deleteMany(
|
|
146
|
+
filter,
|
|
147
|
+
toCollectionOperationOptions(options)
|
|
148
|
+
);
|
|
149
|
+
return {
|
|
150
|
+
acknowledged: result.acknowledged,
|
|
151
|
+
deletedCount: result.deletedCount
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async rename(newName, options) {
|
|
155
|
+
await this.collection.rename(
|
|
156
|
+
newName,
|
|
157
|
+
toCollectionOperationOptions(options)
|
|
158
|
+
);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
drop(options) {
|
|
162
|
+
return this.collection.drop(toCollectionOperationOptions(options));
|
|
163
|
+
}
|
|
164
|
+
async findOne(filter, options) {
|
|
165
|
+
return await this.collection.findOne(
|
|
166
|
+
filter,
|
|
167
|
+
toCollectionOperationOptions(options)
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
find(filter, options) {
|
|
171
|
+
return new FindCursor(
|
|
172
|
+
this.collection.find(
|
|
173
|
+
filter,
|
|
174
|
+
toCollectionOperationOptions(options)
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
options(_options) {
|
|
179
|
+
throw new Error("Method not implemented.");
|
|
180
|
+
}
|
|
181
|
+
isCapped(_options) {
|
|
182
|
+
throw new Error("Method not implemented.");
|
|
183
|
+
}
|
|
184
|
+
createIndex(_indexSpec, _options) {
|
|
185
|
+
throw new Error("Method not implemented.");
|
|
186
|
+
}
|
|
187
|
+
createIndexes(_indexSpecs, _options) {
|
|
188
|
+
throw new Error("Method not implemented.");
|
|
189
|
+
}
|
|
190
|
+
dropIndex(_indexName, _options) {
|
|
191
|
+
throw new Error("Method not implemented.");
|
|
192
|
+
}
|
|
193
|
+
dropIndexes(_options) {
|
|
194
|
+
throw new Error("Method not implemented.");
|
|
195
|
+
}
|
|
196
|
+
listIndexes(_options) {
|
|
197
|
+
throw new Error("Method not implemented.");
|
|
198
|
+
}
|
|
199
|
+
indexExists(_indexes, _options) {
|
|
200
|
+
throw new Error("Method not implemented.");
|
|
201
|
+
}
|
|
202
|
+
indexInformation(_options) {
|
|
203
|
+
throw new Error("Method not implemented.");
|
|
204
|
+
}
|
|
205
|
+
estimatedDocumentCount(options) {
|
|
206
|
+
return this.collection.countDocuments(
|
|
207
|
+
{},
|
|
208
|
+
toCollectionOperationOptions(options)
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
countDocuments(filter, options) {
|
|
212
|
+
return this.collection.countDocuments(
|
|
213
|
+
filter,
|
|
214
|
+
toCollectionOperationOptions(options)
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
distinct(_key, _filter, _options) {
|
|
218
|
+
throw new Error("Method not implemented.");
|
|
219
|
+
}
|
|
220
|
+
indexes(_options) {
|
|
221
|
+
throw new Error("Method not implemented.");
|
|
222
|
+
}
|
|
223
|
+
findOneAndDelete(filter, options) {
|
|
224
|
+
return this.collection.findOneAndDelete(
|
|
225
|
+
filter,
|
|
226
|
+
toCollectionOperationOptions(options)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
findOneAndReplace(filter, replacement, options) {
|
|
230
|
+
return this.collection.findOneAndReplace(
|
|
231
|
+
filter,
|
|
232
|
+
replacement,
|
|
233
|
+
toCollectionOperationOptions(options)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
findOneAndUpdate(filter, update, options) {
|
|
237
|
+
return this.collection.findOneAndUpdate(
|
|
238
|
+
filter,
|
|
239
|
+
update,
|
|
240
|
+
toCollectionOperationOptions(options)
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
aggregate(_pipeline, _options) {
|
|
244
|
+
throw new Error("Method not implemented.");
|
|
245
|
+
}
|
|
246
|
+
watch(_pipeline, _options) {
|
|
247
|
+
throw new Error("Method not implemented.");
|
|
248
|
+
}
|
|
249
|
+
initializeUnorderedBulkOp(_options) {
|
|
250
|
+
throw new Error("Method not implemented.");
|
|
251
|
+
}
|
|
252
|
+
initializeOrderedBulkOp(_options) {
|
|
253
|
+
throw new Error("Method not implemented.");
|
|
254
|
+
}
|
|
255
|
+
count(filter, options) {
|
|
256
|
+
return this.collection.countDocuments(
|
|
257
|
+
_nullishCoalesce(filter, () => ( {})),
|
|
258
|
+
toCollectionOperationOptions(options)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
listSearchIndexes(_name, _options) {
|
|
262
|
+
throw new Error("Method not implemented.");
|
|
263
|
+
}
|
|
264
|
+
createSearchIndex(_description) {
|
|
265
|
+
throw new Error("Method not implemented.");
|
|
266
|
+
}
|
|
267
|
+
createSearchIndexes(_descriptions) {
|
|
268
|
+
throw new Error("Method not implemented.");
|
|
269
|
+
}
|
|
270
|
+
dropSearchIndex(_name) {
|
|
271
|
+
throw new Error("Method not implemented.");
|
|
272
|
+
}
|
|
273
|
+
updateSearchIndex(_name, _definition) {
|
|
274
|
+
throw new Error("Method not implemented.");
|
|
275
|
+
}
|
|
276
|
+
async createCollection() {
|
|
277
|
+
await this.collection.createCollection();
|
|
278
|
+
}
|
|
279
|
+
async handle(id, handle, options) {
|
|
280
|
+
return this.collection.handle(id.toString(), handle, options);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/mongo/mongoDb.ts
|
|
285
|
+
var Db = class {
|
|
286
|
+
constructor(pongoDb) {
|
|
287
|
+
this.pongoDb = pongoDb;
|
|
288
|
+
}
|
|
289
|
+
get databaseName() {
|
|
290
|
+
return this.pongoDb.databaseName;
|
|
291
|
+
}
|
|
292
|
+
collection(collectionName) {
|
|
293
|
+
return new Collection(this.pongoDb.collection(collectionName));
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// src/mongo/mongoClient.ts
|
|
298
|
+
var MongoClient = class {
|
|
299
|
+
|
|
300
|
+
constructor(connectionString, options = {}) {
|
|
301
|
+
this.pongoClient = _chunkHZVM5GBHcjs.pongoClient.call(void 0, connectionString, options);
|
|
302
|
+
}
|
|
303
|
+
async connect() {
|
|
304
|
+
await this.pongoClient.connect();
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
async close() {
|
|
308
|
+
await this.pongoClient.close();
|
|
309
|
+
}
|
|
310
|
+
db(dbName) {
|
|
311
|
+
return new Db(this.pongoClient.db(dbName));
|
|
312
|
+
}
|
|
313
|
+
startSession(_options) {
|
|
314
|
+
return _chunkHZVM5GBHcjs.pongoSession.call(void 0, );
|
|
315
|
+
}
|
|
316
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
|
+
async withSession(optionsOrExecutor, executor) {
|
|
318
|
+
const callback = typeof optionsOrExecutor === "function" ? optionsOrExecutor : executor;
|
|
319
|
+
const session = _chunkHZVM5GBHcjs.pongoSession.call(void 0, );
|
|
320
|
+
try {
|
|
321
|
+
return await callback(session);
|
|
322
|
+
} finally {
|
|
323
|
+
await session.endSession();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
exports.Collection = Collection; exports.Db = Db; exports.FindCursor = FindCursor; exports.MongoClient = MongoClient;
|
|
2
333
|
//# sourceMappingURL=shim.cjs.map
|
package/dist/shim.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts"],"names":["FindCursor","documents","callback","docs","doc","toCollectionOperationOptions","options","Collection","collection"],"mappings":"AAAA,qvBAA+C,ICAlCA,CAAAA,WAAN,KAAoB,CACjB,eACA,SAAA,CAAwB,KAAA,gBACxB,KAAA,CAAgB,EAAA,WAExB,CAAYC,CAAAA,CAAyB,yEACnC,IAAA,CAAK,oBAAA,CAAuBA,CAC9B,CAEA,MAAM,OAAA,CAAA,CAAwB,CAC5B,OAAO,IAAA,CAAK,aAAA,CAAc,CAC5B,CAEA,MAAM,OAAA,CAAQC,CAAAA,CAA2C,CACvD,IAAMC,CAAAA,CAAO,MAAM,IAAA,CAAK,aAAA,CAAc,CAAA,CAEtC,GAAA,CAAA,IAAWC,EAAAA,GAAOD,CAAAA,CAChBD,CAAAA,CAASE,CAAG,CAAA,CAEd,OAAO,OAAA,CAAQ,OAAA,CAAQ,CACzB,CAEA,OAAA,CAAA,CAAmB,CACjB,EAAA,CAAI,IAAA,CAAK,SAAA,GAAc,IAAA,CAAM,MAAM,KAAA,CAAM,gCAAgC,CAAA,CACzE,OAAO,IAAA,CAAK,KAAA,CAAQ,IAAA,CAAK,SAAA,CAAU,MACrC,CAEA,MAAM,IAAA,CAAA,CAA0B,CAC9B,IAAMD,CAAAA,CAAO,MAAM,IAAA,CAAK,aAAA,CAAc,CAAA,CACtC,OAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,kBAAKA,CAAAA,CAAK,IAAA,CAAK,KAAA,EAAO,CAAA,SAAK,MAAA,CAAQ,IACzD,CAEA,MAAc,aAAA,CAAA,CAA8B,CAC1C,OAAA,IAAA,CAAK,SAAA,CAAY,MAAM,IAAA,CAAK,oBAAA,CACrB,IAAA,CAAK,SACd,CACF,UAAA,CCpCA,mBAIO,ICsEDE,CAAAA,CACJC,CAAAA,kBAEAA,CAAAA,2BAAS,SAAA,CACL,CAAE,OAAA,CAASA,CAAAA,CAAQ,OAAmC,CAAA,CACtD,KAAA,CAAA,CAEOC,CAAAA,sBAAN,KAAmE,CAChE,WAER,CAAYC,CAAAA,CAAgC,CAC1C,IAAA,CAAK,UAAA,CAAaA,CACpB,CACA,IAAI,MAAA,CAAA,CAAiB,CACnB,OAAO,IAAA,CAAK,UAAA,CAAW,MACzB,CACA,IAAI,cAAA,CAAA,CAAyB,CAC3B,OAAO,IAAA,CAAK,UAAA,CAAW,cACzB,CACA,IAAI,SAAA,CAAA,CAAoB,CACtB,MAAO,CAAA,EAAA","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","sourcesContent":[null,"export class FindCursor<T> {\n private findDocumentsPromise: Promise<T[]>;\n private documents: T[] | null = null;\n private index: number = 0;\n\n constructor(documents: Promise<T[]>) {\n this.findDocumentsPromise = documents;\n }\n\n async toArray(): Promise<T[]> {\n return this.findDocuments();\n }\n\n async forEach(callback: (doc: T) => void): Promise<void> {\n const docs = await this.findDocuments();\n\n for (const doc of docs) {\n callback(doc);\n }\n return Promise.resolve();\n }\n\n hasNext(): boolean {\n if (this.documents === null) throw Error('Error while fetching documents');\n return this.index < this.documents.length;\n }\n\n async next(): Promise<T | null> {\n const docs = await this.findDocuments();\n return this.hasNext() ? (docs[this.index++] ?? null) : null;\n }\n\n private async findDocuments(): Promise<T[]> {\n this.documents = await this.findDocumentsPromise;\n return this.documents;\n }\n}\n","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type {\n DocumentHandler,\n HandleOptions,\n PongoDb,\n PongoHandleResult,\n} from '../core';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n get databaseName(): string {\n return this.pongoDb.databaseName;\n }\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>>;\n } {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n CollectionOperationOptions,\n DocumentHandler,\n HandleOptions,\n PongoCollection,\n PongoFilter,\n PongoHandleResult,\n OptionalUnlessRequiredId as PongoOptionalUnlessRequiredId,\n PongoSession,\n PongoUpdate,\n} from '../core';\nimport { FindCursor } from './findCursor';\n\nconst toCollectionOperationOptions = (\n options: OperationOptions | undefined,\n): CollectionOperationOptions | undefined =>\n options?.session\n ? { session: options.session as unknown as PongoSession }\n : undefined;\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n return this.collection.dbName;\n }\n get collectionName(): string {\n return this.collection.collectionName;\n }\n get namespace(): string {\n return `${this.dbName}.${this.collectionName}`;\n }\n get readConcern(): ReadConcern | undefined {\n return undefined;\n }\n get readPreference(): ReadPreference | undefined {\n return undefined;\n }\n get bsonOptions(): BSONSerializeOptions {\n return {};\n }\n get writeConcern(): WriteConcern | undefined {\n return undefined;\n }\n get hint(): Hint | undefined {\n return undefined;\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(\n doc as unknown as PongoOptionalUnlessRequiredId<T>,\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(\n docs as unknown as PongoOptionalUnlessRequiredId<T>[],\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n replaceOne(\n filter: Filter<T>,\n document: WithoutId<T>,\n options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n toCollectionOperationOptions(options),\n );\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async rename(\n newName: string,\n options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n await this.collection.rename(\n newName,\n toCollectionOperationOptions(options),\n );\n\n return this as unknown as Collection<Document>;\n }\n drop(options?: DropCollectionOptions | undefined): Promise<boolean> {\n return this.collection.drop(toCollectionOperationOptions(options));\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return (await this.collection.findOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n )) as T;\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n {},\n toCollectionOperationOptions(options),\n );\n }\n countDocuments(\n filter?: Filter<T> | undefined,\n options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: unknown,\n options?: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndDelete(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: unknown,\n replacement: unknown,\n options?: FindOneAndReplaceOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndReplace(\n filter as PongoFilter<T>,\n replacement as WithoutId<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: unknown,\n update: unknown,\n options?: FindOneAndUpdateOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndUpdate(\n filter as PongoFilter<T>,\n update as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n filter?: Filter<T> | undefined,\n options?: CountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n (filter as PongoFilter<T>) ?? {},\n toCollectionOperationOptions(options),\n );\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>> {\n return this.collection.handle(id.toString(), handle, options);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts","../src/mongo/mongoClient.ts"],"names":[],"mappings":"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","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","sourcesContent":[null,"export class FindCursor<T> {\n private findDocumentsPromise: Promise<T[]>;\n private documents: T[] | null = null;\n private index: number = 0;\n\n constructor(documents: Promise<T[]>) {\n this.findDocumentsPromise = documents;\n }\n\n async toArray(): Promise<T[]> {\n return this.findDocuments();\n }\n\n async forEach(callback: (doc: T) => void): Promise<void> {\n const docs = await this.findDocuments();\n\n for (const doc of docs) {\n callback(doc);\n }\n return Promise.resolve();\n }\n\n hasNext(): boolean {\n if (this.documents === null) throw Error('Error while fetching documents');\n return this.index < this.documents.length;\n }\n\n async next(): Promise<T | null> {\n const docs = await this.findDocuments();\n return this.hasNext() ? (docs[this.index++] ?? null) : null;\n }\n\n private async findDocuments(): Promise<T[]> {\n this.documents = await this.findDocumentsPromise;\n return this.documents;\n }\n}\n","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type {\n DocumentHandler,\n HandleOptions,\n PongoDb,\n PongoHandleResult,\n} from '../core';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n get databaseName(): string {\n return this.pongoDb.databaseName;\n }\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>>;\n } {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n CollectionOperationOptions,\n DocumentHandler,\n HandleOptions,\n PongoCollection,\n PongoFilter,\n PongoHandleResult,\n OptionalUnlessRequiredId as PongoOptionalUnlessRequiredId,\n PongoSession,\n PongoUpdate,\n} from '../core';\nimport { FindCursor } from './findCursor';\n\nconst toCollectionOperationOptions = (\n options: OperationOptions | undefined,\n): CollectionOperationOptions | undefined =>\n options?.session\n ? { session: options.session as unknown as PongoSession }\n : undefined;\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n return this.collection.dbName;\n }\n get collectionName(): string {\n return this.collection.collectionName;\n }\n get namespace(): string {\n return `${this.dbName}.${this.collectionName}`;\n }\n get readConcern(): ReadConcern | undefined {\n return undefined;\n }\n get readPreference(): ReadPreference | undefined {\n return undefined;\n }\n get bsonOptions(): BSONSerializeOptions {\n return {};\n }\n get writeConcern(): WriteConcern | undefined {\n return undefined;\n }\n get hint(): Hint | undefined {\n return undefined;\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(\n doc as unknown as PongoOptionalUnlessRequiredId<T>,\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(\n docs as unknown as PongoOptionalUnlessRequiredId<T>[],\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n replaceOne(\n filter: Filter<T>,\n document: WithoutId<T>,\n options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n toCollectionOperationOptions(options),\n );\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async rename(\n newName: string,\n options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n await this.collection.rename(\n newName,\n toCollectionOperationOptions(options),\n );\n\n return this as unknown as Collection<Document>;\n }\n drop(options?: DropCollectionOptions | undefined): Promise<boolean> {\n return this.collection.drop(toCollectionOperationOptions(options));\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return (await this.collection.findOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n )) as T;\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n {},\n toCollectionOperationOptions(options),\n );\n }\n countDocuments(\n filter?: Filter<T> | undefined,\n options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: unknown,\n options?: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndDelete(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: unknown,\n replacement: unknown,\n options?: FindOneAndReplaceOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndReplace(\n filter as PongoFilter<T>,\n replacement as WithoutId<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: unknown,\n update: unknown,\n options?: FindOneAndUpdateOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndUpdate(\n filter as PongoFilter<T>,\n update as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n filter?: Filter<T> | undefined,\n options?: CountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n (filter as PongoFilter<T>) ?? {},\n toCollectionOperationOptions(options),\n );\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>> {\n return this.collection.handle(id.toString(), handle, options);\n }\n}\n","import type { ClientSessionOptions } from 'http2';\nimport type { ClientSession, WithSessionCallback } from 'mongodb';\nimport {\n pongoClient,\n pongoSession,\n type PongoClient,\n type PongoClientOptions,\n} from '../core';\nimport { Db } from './mongoDb';\n\nexport class MongoClient {\n private pongoClient: PongoClient;\n\n constructor(connectionString: string, options: PongoClientOptions = {}) {\n this.pongoClient = pongoClient(connectionString, options);\n }\n\n async connect() {\n await this.pongoClient.connect();\n return this;\n }\n\n async close() {\n await this.pongoClient.close();\n }\n\n db(dbName?: string): Db {\n return new Db(this.pongoClient.db(dbName));\n }\n startSession(_options?: ClientSessionOptions): ClientSession {\n return pongoSession() as unknown as ClientSession;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n withSession<T = any>(_executor: WithSessionCallback<T>): Promise<T>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n withSession<T = any>(\n _options: ClientSessionOptions,\n _executor: WithSessionCallback<T>,\n ): Promise<T>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async withSession<T = any>(\n optionsOrExecutor: ClientSessionOptions | WithSessionCallback<T>,\n executor?: WithSessionCallback<T>,\n ): Promise<T> {\n const callback =\n typeof optionsOrExecutor === 'function' ? optionsOrExecutor : executor!;\n\n const session = pongoSession() as unknown as ClientSession;\n\n try {\n return await callback(session);\n } finally {\n await session.endSession();\n }\n }\n}\n"]}
|