@event-driven-io/pongo 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +149 -79
- package/dist/index.d.ts +149 -79
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
|
+
import { SQLExecutor, SQL, PostgresConnector, PostgresPoolOptions, DatabaseTransaction, DatabaseTransactionFactory } from '@event-driven-io/dumbo';
|
|
1
2
|
import pg from 'pg';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { ClientSessionOptions } from 'http2';
|
|
4
|
+
import { Document, Collection as Collection$1, ObjectId as ObjectId$1, ClientSession, WithSessionCallback, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId as WithoutId$1, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type PongoCollectionOptions<ConnectorType extends string = string> = {
|
|
7
|
+
db: PongoDb<ConnectorType>;
|
|
8
|
+
collectionName: string;
|
|
9
|
+
sqlExecutor: SQLExecutor;
|
|
10
|
+
sqlBuilder: PongoCollectionSQLBuilder;
|
|
11
|
+
};
|
|
12
|
+
declare const pongoCollection: <T extends PongoDocument, ConnectorType extends string = string>({ db, collectionName, sqlExecutor, sqlBuilder: SqlFor, }: PongoCollectionOptions<ConnectorType>) => PongoCollection<T>;
|
|
13
|
+
type PongoCollectionSQLBuilder = {
|
|
14
|
+
createCollection: () => SQL;
|
|
15
|
+
insertOne: <T>(document: WithId<T>) => SQL;
|
|
16
|
+
insertMany: <T>(documents: WithId<T>[]) => SQL;
|
|
17
|
+
updateOne: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>) => SQL;
|
|
18
|
+
replaceOne: <T>(filter: PongoFilter<T>, document: WithoutId<T>) => SQL;
|
|
19
|
+
updateMany: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>) => SQL;
|
|
20
|
+
deleteOne: <T>(filter: PongoFilter<T>) => SQL;
|
|
21
|
+
deleteMany: <T>(filter: PongoFilter<T>) => SQL;
|
|
22
|
+
findOne: <T>(filter: PongoFilter<T>) => SQL;
|
|
23
|
+
find: <T>(filter: PongoFilter<T>) => SQL;
|
|
24
|
+
countDocuments: <T>(filter: PongoFilter<T>) => SQL;
|
|
25
|
+
rename: (newName: string) => SQL;
|
|
26
|
+
drop: () => SQL;
|
|
9
27
|
};
|
|
10
|
-
declare const postgresClient: (options: PongoClientOptions) => DbClient;
|
|
11
28
|
|
|
12
|
-
declare const
|
|
29
|
+
declare const QueryOperators: {
|
|
13
30
|
$eq: string;
|
|
14
31
|
$gt: string;
|
|
15
32
|
$gte: string;
|
|
@@ -22,66 +39,88 @@ declare const Operators: {
|
|
|
22
39
|
$all: string;
|
|
23
40
|
$size: string;
|
|
24
41
|
};
|
|
42
|
+
declare const OperatorMap: {
|
|
43
|
+
$gt: string;
|
|
44
|
+
$gte: string;
|
|
45
|
+
$lt: string;
|
|
46
|
+
$lte: string;
|
|
47
|
+
$ne: string;
|
|
48
|
+
};
|
|
25
49
|
declare const isOperator: (key: string) => boolean;
|
|
26
50
|
declare const hasOperators: (value: Record<string, unknown>) => boolean;
|
|
27
|
-
declare const handleOperator: (path: string, operator: string, value: unknown) => string;
|
|
28
51
|
|
|
29
|
-
|
|
52
|
+
type PostgresDbClientOptions = PongoDbClientOptions<PostgresConnector> & PostgresPoolOptions;
|
|
53
|
+
declare const isPostgresClientOptions: (options: PongoDbClientOptions) => options is PostgresDbClientOptions;
|
|
54
|
+
declare const postgresDb: (options: PostgresDbClientOptions) => PongoDb<PostgresConnector>;
|
|
30
55
|
|
|
31
|
-
declare const
|
|
32
|
-
dbName: string;
|
|
33
|
-
poolOrClient: pg.Pool | pg.PoolClient | pg.Client;
|
|
34
|
-
}) => PongoCollection<T>;
|
|
35
|
-
declare const collectionSQLBuilder: (collectionName: string) => {
|
|
36
|
-
createCollection: () => SQL;
|
|
37
|
-
insertOne: <T>(document: WithId<T>) => SQL;
|
|
38
|
-
insertMany: <T_1>(documents: WithId<T_1>[]) => SQL;
|
|
39
|
-
updateOne: <T_2>(filter: PongoFilter<T_2>, update: PongoUpdate<T_2>) => SQL;
|
|
40
|
-
replaceOne: <T_3>(filter: PongoFilter<T_3>, document: WithoutId<T_3>) => SQL;
|
|
41
|
-
updateMany: <T_4>(filter: PongoFilter<T_4>, update: PongoUpdate<T_4>) => SQL;
|
|
42
|
-
deleteOne: <T_5>(filter: PongoFilter<T_5>) => SQL;
|
|
43
|
-
deleteMany: <T_6>(filter: PongoFilter<T_6>) => SQL;
|
|
44
|
-
findOne: <T_7>(filter: PongoFilter<T_7>) => SQL;
|
|
45
|
-
find: <T_8>(filter: PongoFilter<T_8>) => SQL;
|
|
46
|
-
countDocuments: <T_9>(filter: PongoFilter<T_9>) => SQL;
|
|
47
|
-
rename: (newName: string) => SQL;
|
|
48
|
-
drop: (targetName?: string) => SQL;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
declare const buildUpdateQuery: <T>(update: PongoUpdate<T>) => SQL;
|
|
52
|
-
declare const buildSetQuery: <T>(set: $set<T>, currentUpdateQuery: SQL) => SQL;
|
|
53
|
-
declare const buildUnsetQuery: <T>(unset: $unset<T>, currentUpdateQuery: SQL) => SQL;
|
|
54
|
-
declare const buildIncQuery: <T>(inc: $inc<T>, currentUpdateQuery: SQL) => SQL;
|
|
55
|
-
declare const buildPushQuery: <T>(push: $push<T>, currentUpdateQuery: SQL) => SQL;
|
|
56
|
+
declare const postgresSQLBuilder: (collectionName: string) => PongoCollectionSQLBuilder;
|
|
56
57
|
|
|
57
58
|
interface PongoClient {
|
|
58
59
|
connect(): Promise<this>;
|
|
59
60
|
close(): Promise<void>;
|
|
60
61
|
db(dbName?: string): PongoDb;
|
|
62
|
+
startSession(): PongoSession;
|
|
63
|
+
withSession<T = unknown>(callback: (session: PongoSession) => Promise<T>): Promise<T>;
|
|
64
|
+
}
|
|
65
|
+
declare interface PongoTransactionOptions {
|
|
66
|
+
get snapshotEnabled(): boolean;
|
|
67
|
+
maxCommitTimeMS?: number;
|
|
68
|
+
}
|
|
69
|
+
interface PongoDbTransaction {
|
|
70
|
+
get databaseName(): string | null;
|
|
71
|
+
options: PongoTransactionOptions;
|
|
72
|
+
enlistDatabase: (database: PongoDb) => Promise<DatabaseTransaction>;
|
|
73
|
+
commit: () => Promise<void>;
|
|
74
|
+
rollback: (error?: unknown) => Promise<void>;
|
|
75
|
+
get sqlExecutor(): SQLExecutor;
|
|
76
|
+
get isStarting(): boolean;
|
|
77
|
+
get isActive(): boolean;
|
|
78
|
+
get isCommitted(): boolean;
|
|
61
79
|
}
|
|
62
|
-
interface
|
|
80
|
+
interface PongoSession {
|
|
81
|
+
hasEnded: boolean;
|
|
82
|
+
explicit: boolean;
|
|
83
|
+
defaultTransactionOptions: PongoTransactionOptions;
|
|
84
|
+
transaction: PongoDbTransaction | null;
|
|
85
|
+
get snapshotEnabled(): boolean;
|
|
86
|
+
endSession(): Promise<void>;
|
|
87
|
+
incrementTransactionNumber(): void;
|
|
88
|
+
inTransaction(): boolean;
|
|
89
|
+
startTransaction(options?: PongoTransactionOptions): void;
|
|
90
|
+
commitTransaction(): Promise<void>;
|
|
91
|
+
abortTransaction(): Promise<void>;
|
|
92
|
+
withTransaction<T = unknown>(fn: (session: PongoSession) => Promise<T>, options?: PongoTransactionOptions): Promise<T>;
|
|
93
|
+
}
|
|
94
|
+
interface PongoDb<ConnectorType extends string = string> extends DatabaseTransactionFactory<ConnectorType> {
|
|
95
|
+
get connectorType(): ConnectorType;
|
|
96
|
+
get databaseName(): string;
|
|
97
|
+
connect(): Promise<void>;
|
|
98
|
+
close(): Promise<void>;
|
|
63
99
|
collection<T extends PongoDocument>(name: string): PongoCollection<T>;
|
|
64
100
|
}
|
|
101
|
+
type CollectionOperationOptions = {
|
|
102
|
+
session?: PongoSession;
|
|
103
|
+
};
|
|
65
104
|
interface PongoCollection<T extends PongoDocument> {
|
|
66
105
|
readonly dbName: string;
|
|
67
106
|
readonly collectionName: string;
|
|
68
|
-
createCollection(): Promise<void>;
|
|
69
|
-
insertOne(document: T): Promise<PongoInsertOneResult>;
|
|
70
|
-
insertMany(documents: T[]): Promise<PongoInsertManyResult>;
|
|
71
|
-
updateOne(filter: PongoFilter<T>, update: PongoUpdate<T
|
|
72
|
-
replaceOne(filter: PongoFilter<T>, document: WithoutId<T
|
|
73
|
-
updateMany(filter: PongoFilter<T>, update: PongoUpdate<T
|
|
74
|
-
deleteOne(filter?: PongoFilter<T
|
|
75
|
-
deleteMany(filter?: PongoFilter<T
|
|
76
|
-
findOne(filter?: PongoFilter<T
|
|
77
|
-
find(filter?: PongoFilter<T
|
|
78
|
-
findOneAndDelete(filter: PongoFilter<T
|
|
79
|
-
findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T
|
|
80
|
-
findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T
|
|
81
|
-
countDocuments(filter?: PongoFilter<T
|
|
82
|
-
drop(): Promise<boolean>;
|
|
83
|
-
rename(newName: string): Promise<PongoCollection<T>>;
|
|
84
|
-
handle(id: string, handle: DocumentHandler<T
|
|
107
|
+
createCollection(options?: CollectionOperationOptions): Promise<void>;
|
|
108
|
+
insertOne(document: T, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
|
|
109
|
+
insertMany(documents: T[], options?: CollectionOperationOptions): Promise<PongoInsertManyResult>;
|
|
110
|
+
updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
|
|
111
|
+
replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
|
|
112
|
+
updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
|
|
113
|
+
deleteOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
|
|
114
|
+
deleteMany(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
|
|
115
|
+
findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
116
|
+
find(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T[]>;
|
|
117
|
+
findOneAndDelete(filter: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
118
|
+
findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
119
|
+
findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
120
|
+
countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
|
|
121
|
+
drop(options?: CollectionOperationOptions): Promise<boolean>;
|
|
122
|
+
rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
|
|
123
|
+
handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
85
124
|
}
|
|
86
125
|
type HasId = {
|
|
87
126
|
_id: string;
|
|
@@ -145,16 +184,29 @@ interface PongoDeleteManyResult {
|
|
|
145
184
|
type PongoDocument = Record<string, unknown>;
|
|
146
185
|
type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
|
|
147
186
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
187
|
+
type PooledPongoClientOptions = {
|
|
188
|
+
pool: pg.Pool;
|
|
189
|
+
} | {
|
|
190
|
+
pooled: true;
|
|
191
|
+
} | {
|
|
192
|
+
pool: pg.Pool;
|
|
193
|
+
pooled: true;
|
|
194
|
+
} | {};
|
|
195
|
+
type NotPooledPongoOptions = {
|
|
196
|
+
client: pg.Client;
|
|
197
|
+
} | {
|
|
198
|
+
pooled: false;
|
|
199
|
+
} | {
|
|
200
|
+
client: pg.Client;
|
|
201
|
+
pooled: false;
|
|
202
|
+
};
|
|
203
|
+
type PongoClientOptions = PooledPongoClientOptions | NotPooledPongoOptions;
|
|
204
|
+
declare const pongoClient: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions) => PongoClient;
|
|
205
|
+
declare const clientToDbOptions: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: {
|
|
206
|
+
connectionString: string;
|
|
207
|
+
dbName?: string;
|
|
208
|
+
clientOptions: PongoClientOptions;
|
|
209
|
+
}) => DbClientOptions;
|
|
158
210
|
|
|
159
211
|
type Entry<T> = {
|
|
160
212
|
[K in keyof Required<T>]: [K, Required<T>[K]];
|
|
@@ -167,6 +219,22 @@ type NonPartial<T> = {
|
|
|
167
219
|
[K in keyof Required<T>]: T[K];
|
|
168
220
|
};
|
|
169
221
|
|
|
222
|
+
type PongoDbClientOptions<ConnectorType extends string = string> = {
|
|
223
|
+
connectorType: ConnectorType;
|
|
224
|
+
connectionString: string;
|
|
225
|
+
dbName: string | undefined;
|
|
226
|
+
};
|
|
227
|
+
type AllowedDbClientOptions = PostgresDbClientOptions;
|
|
228
|
+
declare const getPongoDb: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: DbClientOptions) => PongoDb;
|
|
229
|
+
|
|
230
|
+
type PongoSessionOptions = {
|
|
231
|
+
explicit?: boolean;
|
|
232
|
+
defaultTransactionOptions: PongoTransactionOptions;
|
|
233
|
+
};
|
|
234
|
+
declare const pongoSession: (options?: PongoSessionOptions) => PongoSession;
|
|
235
|
+
|
|
236
|
+
declare const pongoTransaction: (options: PongoTransactionOptions) => PongoDbTransaction;
|
|
237
|
+
|
|
170
238
|
declare class FindCursor<T> {
|
|
171
239
|
private findDocumentsPromise;
|
|
172
240
|
private documents;
|
|
@@ -182,6 +250,7 @@ declare class FindCursor<T> {
|
|
|
182
250
|
declare class Db {
|
|
183
251
|
private pongoDb;
|
|
184
252
|
constructor(pongoDb: PongoDb);
|
|
253
|
+
get databaseName(): string;
|
|
185
254
|
collection<T extends Document>(collectionName: string): Collection$1<T> & {
|
|
186
255
|
handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
|
|
187
256
|
};
|
|
@@ -189,12 +258,13 @@ declare class Db {
|
|
|
189
258
|
|
|
190
259
|
declare class MongoClient {
|
|
191
260
|
private pongoClient;
|
|
192
|
-
constructor(connectionString: string, options?:
|
|
193
|
-
client?: pg.PoolClient | pg.Client;
|
|
194
|
-
});
|
|
261
|
+
constructor(connectionString: string, options?: PongoClientOptions);
|
|
195
262
|
connect(): Promise<this>;
|
|
196
263
|
close(): Promise<void>;
|
|
197
264
|
db(dbName?: string): Db;
|
|
265
|
+
startSession(_options?: ClientSessionOptions): ClientSession;
|
|
266
|
+
withSession<T = any>(_executor: WithSessionCallback<T>): Promise<T>;
|
|
267
|
+
withSession<T = any>(_options: ClientSessionOptions, _executor: WithSessionCallback<T>): Promise<T>;
|
|
198
268
|
}
|
|
199
269
|
|
|
200
270
|
declare class Collection<T extends Document> implements Collection$1<T> {
|
|
@@ -209,16 +279,16 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
209
279
|
get writeConcern(): WriteConcern | undefined;
|
|
210
280
|
get hint(): Hint | undefined;
|
|
211
281
|
set hint(v: Hint | undefined);
|
|
212
|
-
insertOne(doc: OptionalUnlessRequiredId<T>,
|
|
213
|
-
insertMany(docs: OptionalUnlessRequiredId<T>[],
|
|
282
|
+
insertOne(doc: OptionalUnlessRequiredId<T>, options?: InsertOneOptions | undefined): Promise<InsertOneResult<T>>;
|
|
283
|
+
insertMany(docs: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
|
|
214
284
|
bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
|
|
215
|
-
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>,
|
|
216
|
-
replaceOne(filter: Filter<T>, document: WithoutId$1<T>,
|
|
217
|
-
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>,
|
|
218
|
-
deleteOne(filter?: Filter<T> | undefined,
|
|
219
|
-
deleteMany(filter?: Filter<T> | undefined,
|
|
220
|
-
rename(newName: string,
|
|
221
|
-
drop(
|
|
285
|
+
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
286
|
+
replaceOne(filter: Filter<T>, document: WithoutId$1<T>, options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
|
|
287
|
+
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
288
|
+
deleteOne(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
289
|
+
deleteMany(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
290
|
+
rename(newName: string, options?: RenameOptions | undefined): Promise<Collection<Document>>;
|
|
291
|
+
drop(options?: DropCollectionOptions | undefined): Promise<boolean>;
|
|
222
292
|
findOne(): Promise<WithId$1<T> | null>;
|
|
223
293
|
findOne(filter: Filter<T>): Promise<WithId$1<T> | null>;
|
|
224
294
|
findOne(filter: Filter<T>, options: FindOptions<Document>): Promise<WithId$1<T> | null>;
|
|
@@ -244,8 +314,8 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
244
314
|
}): Promise<IndexDescriptionCompact>;
|
|
245
315
|
indexInformation(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
|
|
246
316
|
indexInformation(): Promise<IndexDescriptionCompact>;
|
|
247
|
-
estimatedDocumentCount(
|
|
248
|
-
countDocuments(filter?: Filter<T> | undefined,
|
|
317
|
+
estimatedDocumentCount(options?: EstimatedDocumentCountOptions | undefined): Promise<number>;
|
|
318
|
+
countDocuments(filter?: Filter<T> | undefined, options?: CountDocumentsOptions | undefined): Promise<number>;
|
|
249
319
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
250
320
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
251
321
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>, options: CommandOperationOptions): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
@@ -288,7 +358,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
288
358
|
watch<TLocal extends Document = T, TChange extends Document = ChangeStreamDocument<TLocal>>(_pipeline?: Document[] | undefined, _options?: ChangeStreamOptions | undefined): ChangeStream<TLocal, TChange>;
|
|
289
359
|
initializeUnorderedBulkOp(_options?: BulkWriteOptions | undefined): UnorderedBulkOperation;
|
|
290
360
|
initializeOrderedBulkOp(_options?: BulkWriteOptions | undefined): OrderedBulkOperation;
|
|
291
|
-
count(filter?: Filter<T> | undefined,
|
|
361
|
+
count(filter?: Filter<T> | undefined, options?: CountOptions | undefined): Promise<number>;
|
|
292
362
|
listSearchIndexes(options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
|
|
293
363
|
listSearchIndexes(name: string, options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
|
|
294
364
|
createSearchIndex(_description: SearchIndexDescription): Promise<string>;
|
|
@@ -303,4 +373,4 @@ type ObjectId = string & {
|
|
|
303
373
|
__brandId: 'ObjectId';
|
|
304
374
|
};
|
|
305
375
|
|
|
306
|
-
export { type $inc, type $push, type $set, type $unset,
|
|
376
|
+
export { type $inc, type $push, type $set, type $unset, type AllowedDbClientOptions, Collection, type CollectionOperationOptions, Db, type DocumentHandler, FindCursor, type HasId, MongoClient, type NonPartial, type NotPooledPongoOptions, type ObjectId, OperatorMap, type PongoClient, type PongoClientOptions, type PongoCollection, type PongoCollectionOptions, type PongoCollectionSQLBuilder, type PongoDb, type PongoDbClientOptions, type PongoDbTransaction, type PongoDeleteManyResult, type PongoDeleteResult, type PongoDocument, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoSession, type PongoSessionOptions, type PongoTransactionOptions, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type PooledPongoClientOptions, type PostgresDbClientOptions, QueryOperators, type WithId, type WithoutId, clientToDbOptions, entries, getPongoDb, hasOperators, isOperator, isPostgresClientOptions, pongoClient, pongoCollection, pongoSession, pongoTransaction, postgresDb, postgresSQLBuilder };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
|
+
import { SQLExecutor, SQL, PostgresConnector, PostgresPoolOptions, DatabaseTransaction, DatabaseTransactionFactory } from '@event-driven-io/dumbo';
|
|
1
2
|
import pg from 'pg';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { ClientSessionOptions } from 'http2';
|
|
4
|
+
import { Document, Collection as Collection$1, ObjectId as ObjectId$1, ClientSession, WithSessionCallback, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId as WithoutId$1, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
|
|
4
5
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type PongoCollectionOptions<ConnectorType extends string = string> = {
|
|
7
|
+
db: PongoDb<ConnectorType>;
|
|
8
|
+
collectionName: string;
|
|
9
|
+
sqlExecutor: SQLExecutor;
|
|
10
|
+
sqlBuilder: PongoCollectionSQLBuilder;
|
|
11
|
+
};
|
|
12
|
+
declare const pongoCollection: <T extends PongoDocument, ConnectorType extends string = string>({ db, collectionName, sqlExecutor, sqlBuilder: SqlFor, }: PongoCollectionOptions<ConnectorType>) => PongoCollection<T>;
|
|
13
|
+
type PongoCollectionSQLBuilder = {
|
|
14
|
+
createCollection: () => SQL;
|
|
15
|
+
insertOne: <T>(document: WithId<T>) => SQL;
|
|
16
|
+
insertMany: <T>(documents: WithId<T>[]) => SQL;
|
|
17
|
+
updateOne: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>) => SQL;
|
|
18
|
+
replaceOne: <T>(filter: PongoFilter<T>, document: WithoutId<T>) => SQL;
|
|
19
|
+
updateMany: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>) => SQL;
|
|
20
|
+
deleteOne: <T>(filter: PongoFilter<T>) => SQL;
|
|
21
|
+
deleteMany: <T>(filter: PongoFilter<T>) => SQL;
|
|
22
|
+
findOne: <T>(filter: PongoFilter<T>) => SQL;
|
|
23
|
+
find: <T>(filter: PongoFilter<T>) => SQL;
|
|
24
|
+
countDocuments: <T>(filter: PongoFilter<T>) => SQL;
|
|
25
|
+
rename: (newName: string) => SQL;
|
|
26
|
+
drop: () => SQL;
|
|
9
27
|
};
|
|
10
|
-
declare const postgresClient: (options: PongoClientOptions) => DbClient;
|
|
11
28
|
|
|
12
|
-
declare const
|
|
29
|
+
declare const QueryOperators: {
|
|
13
30
|
$eq: string;
|
|
14
31
|
$gt: string;
|
|
15
32
|
$gte: string;
|
|
@@ -22,66 +39,88 @@ declare const Operators: {
|
|
|
22
39
|
$all: string;
|
|
23
40
|
$size: string;
|
|
24
41
|
};
|
|
42
|
+
declare const OperatorMap: {
|
|
43
|
+
$gt: string;
|
|
44
|
+
$gte: string;
|
|
45
|
+
$lt: string;
|
|
46
|
+
$lte: string;
|
|
47
|
+
$ne: string;
|
|
48
|
+
};
|
|
25
49
|
declare const isOperator: (key: string) => boolean;
|
|
26
50
|
declare const hasOperators: (value: Record<string, unknown>) => boolean;
|
|
27
|
-
declare const handleOperator: (path: string, operator: string, value: unknown) => string;
|
|
28
51
|
|
|
29
|
-
|
|
52
|
+
type PostgresDbClientOptions = PongoDbClientOptions<PostgresConnector> & PostgresPoolOptions;
|
|
53
|
+
declare const isPostgresClientOptions: (options: PongoDbClientOptions) => options is PostgresDbClientOptions;
|
|
54
|
+
declare const postgresDb: (options: PostgresDbClientOptions) => PongoDb<PostgresConnector>;
|
|
30
55
|
|
|
31
|
-
declare const
|
|
32
|
-
dbName: string;
|
|
33
|
-
poolOrClient: pg.Pool | pg.PoolClient | pg.Client;
|
|
34
|
-
}) => PongoCollection<T>;
|
|
35
|
-
declare const collectionSQLBuilder: (collectionName: string) => {
|
|
36
|
-
createCollection: () => SQL;
|
|
37
|
-
insertOne: <T>(document: WithId<T>) => SQL;
|
|
38
|
-
insertMany: <T_1>(documents: WithId<T_1>[]) => SQL;
|
|
39
|
-
updateOne: <T_2>(filter: PongoFilter<T_2>, update: PongoUpdate<T_2>) => SQL;
|
|
40
|
-
replaceOne: <T_3>(filter: PongoFilter<T_3>, document: WithoutId<T_3>) => SQL;
|
|
41
|
-
updateMany: <T_4>(filter: PongoFilter<T_4>, update: PongoUpdate<T_4>) => SQL;
|
|
42
|
-
deleteOne: <T_5>(filter: PongoFilter<T_5>) => SQL;
|
|
43
|
-
deleteMany: <T_6>(filter: PongoFilter<T_6>) => SQL;
|
|
44
|
-
findOne: <T_7>(filter: PongoFilter<T_7>) => SQL;
|
|
45
|
-
find: <T_8>(filter: PongoFilter<T_8>) => SQL;
|
|
46
|
-
countDocuments: <T_9>(filter: PongoFilter<T_9>) => SQL;
|
|
47
|
-
rename: (newName: string) => SQL;
|
|
48
|
-
drop: (targetName?: string) => SQL;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
declare const buildUpdateQuery: <T>(update: PongoUpdate<T>) => SQL;
|
|
52
|
-
declare const buildSetQuery: <T>(set: $set<T>, currentUpdateQuery: SQL) => SQL;
|
|
53
|
-
declare const buildUnsetQuery: <T>(unset: $unset<T>, currentUpdateQuery: SQL) => SQL;
|
|
54
|
-
declare const buildIncQuery: <T>(inc: $inc<T>, currentUpdateQuery: SQL) => SQL;
|
|
55
|
-
declare const buildPushQuery: <T>(push: $push<T>, currentUpdateQuery: SQL) => SQL;
|
|
56
|
+
declare const postgresSQLBuilder: (collectionName: string) => PongoCollectionSQLBuilder;
|
|
56
57
|
|
|
57
58
|
interface PongoClient {
|
|
58
59
|
connect(): Promise<this>;
|
|
59
60
|
close(): Promise<void>;
|
|
60
61
|
db(dbName?: string): PongoDb;
|
|
62
|
+
startSession(): PongoSession;
|
|
63
|
+
withSession<T = unknown>(callback: (session: PongoSession) => Promise<T>): Promise<T>;
|
|
64
|
+
}
|
|
65
|
+
declare interface PongoTransactionOptions {
|
|
66
|
+
get snapshotEnabled(): boolean;
|
|
67
|
+
maxCommitTimeMS?: number;
|
|
68
|
+
}
|
|
69
|
+
interface PongoDbTransaction {
|
|
70
|
+
get databaseName(): string | null;
|
|
71
|
+
options: PongoTransactionOptions;
|
|
72
|
+
enlistDatabase: (database: PongoDb) => Promise<DatabaseTransaction>;
|
|
73
|
+
commit: () => Promise<void>;
|
|
74
|
+
rollback: (error?: unknown) => Promise<void>;
|
|
75
|
+
get sqlExecutor(): SQLExecutor;
|
|
76
|
+
get isStarting(): boolean;
|
|
77
|
+
get isActive(): boolean;
|
|
78
|
+
get isCommitted(): boolean;
|
|
61
79
|
}
|
|
62
|
-
interface
|
|
80
|
+
interface PongoSession {
|
|
81
|
+
hasEnded: boolean;
|
|
82
|
+
explicit: boolean;
|
|
83
|
+
defaultTransactionOptions: PongoTransactionOptions;
|
|
84
|
+
transaction: PongoDbTransaction | null;
|
|
85
|
+
get snapshotEnabled(): boolean;
|
|
86
|
+
endSession(): Promise<void>;
|
|
87
|
+
incrementTransactionNumber(): void;
|
|
88
|
+
inTransaction(): boolean;
|
|
89
|
+
startTransaction(options?: PongoTransactionOptions): void;
|
|
90
|
+
commitTransaction(): Promise<void>;
|
|
91
|
+
abortTransaction(): Promise<void>;
|
|
92
|
+
withTransaction<T = unknown>(fn: (session: PongoSession) => Promise<T>, options?: PongoTransactionOptions): Promise<T>;
|
|
93
|
+
}
|
|
94
|
+
interface PongoDb<ConnectorType extends string = string> extends DatabaseTransactionFactory<ConnectorType> {
|
|
95
|
+
get connectorType(): ConnectorType;
|
|
96
|
+
get databaseName(): string;
|
|
97
|
+
connect(): Promise<void>;
|
|
98
|
+
close(): Promise<void>;
|
|
63
99
|
collection<T extends PongoDocument>(name: string): PongoCollection<T>;
|
|
64
100
|
}
|
|
101
|
+
type CollectionOperationOptions = {
|
|
102
|
+
session?: PongoSession;
|
|
103
|
+
};
|
|
65
104
|
interface PongoCollection<T extends PongoDocument> {
|
|
66
105
|
readonly dbName: string;
|
|
67
106
|
readonly collectionName: string;
|
|
68
|
-
createCollection(): Promise<void>;
|
|
69
|
-
insertOne(document: T): Promise<PongoInsertOneResult>;
|
|
70
|
-
insertMany(documents: T[]): Promise<PongoInsertManyResult>;
|
|
71
|
-
updateOne(filter: PongoFilter<T>, update: PongoUpdate<T
|
|
72
|
-
replaceOne(filter: PongoFilter<T>, document: WithoutId<T
|
|
73
|
-
updateMany(filter: PongoFilter<T>, update: PongoUpdate<T
|
|
74
|
-
deleteOne(filter?: PongoFilter<T
|
|
75
|
-
deleteMany(filter?: PongoFilter<T
|
|
76
|
-
findOne(filter?: PongoFilter<T
|
|
77
|
-
find(filter?: PongoFilter<T
|
|
78
|
-
findOneAndDelete(filter: PongoFilter<T
|
|
79
|
-
findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T
|
|
80
|
-
findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T
|
|
81
|
-
countDocuments(filter?: PongoFilter<T
|
|
82
|
-
drop(): Promise<boolean>;
|
|
83
|
-
rename(newName: string): Promise<PongoCollection<T>>;
|
|
84
|
-
handle(id: string, handle: DocumentHandler<T
|
|
107
|
+
createCollection(options?: CollectionOperationOptions): Promise<void>;
|
|
108
|
+
insertOne(document: T, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
|
|
109
|
+
insertMany(documents: T[], options?: CollectionOperationOptions): Promise<PongoInsertManyResult>;
|
|
110
|
+
updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
|
|
111
|
+
replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
|
|
112
|
+
updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
|
|
113
|
+
deleteOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
|
|
114
|
+
deleteMany(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
|
|
115
|
+
findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
116
|
+
find(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T[]>;
|
|
117
|
+
findOneAndDelete(filter: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
118
|
+
findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
119
|
+
findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
120
|
+
countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
|
|
121
|
+
drop(options?: CollectionOperationOptions): Promise<boolean>;
|
|
122
|
+
rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
|
|
123
|
+
handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
|
|
85
124
|
}
|
|
86
125
|
type HasId = {
|
|
87
126
|
_id: string;
|
|
@@ -145,16 +184,29 @@ interface PongoDeleteManyResult {
|
|
|
145
184
|
type PongoDocument = Record<string, unknown>;
|
|
146
185
|
type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
|
|
147
186
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
187
|
+
type PooledPongoClientOptions = {
|
|
188
|
+
pool: pg.Pool;
|
|
189
|
+
} | {
|
|
190
|
+
pooled: true;
|
|
191
|
+
} | {
|
|
192
|
+
pool: pg.Pool;
|
|
193
|
+
pooled: true;
|
|
194
|
+
} | {};
|
|
195
|
+
type NotPooledPongoOptions = {
|
|
196
|
+
client: pg.Client;
|
|
197
|
+
} | {
|
|
198
|
+
pooled: false;
|
|
199
|
+
} | {
|
|
200
|
+
client: pg.Client;
|
|
201
|
+
pooled: false;
|
|
202
|
+
};
|
|
203
|
+
type PongoClientOptions = PooledPongoClientOptions | NotPooledPongoOptions;
|
|
204
|
+
declare const pongoClient: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions) => PongoClient;
|
|
205
|
+
declare const clientToDbOptions: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: {
|
|
206
|
+
connectionString: string;
|
|
207
|
+
dbName?: string;
|
|
208
|
+
clientOptions: PongoClientOptions;
|
|
209
|
+
}) => DbClientOptions;
|
|
158
210
|
|
|
159
211
|
type Entry<T> = {
|
|
160
212
|
[K in keyof Required<T>]: [K, Required<T>[K]];
|
|
@@ -167,6 +219,22 @@ type NonPartial<T> = {
|
|
|
167
219
|
[K in keyof Required<T>]: T[K];
|
|
168
220
|
};
|
|
169
221
|
|
|
222
|
+
type PongoDbClientOptions<ConnectorType extends string = string> = {
|
|
223
|
+
connectorType: ConnectorType;
|
|
224
|
+
connectionString: string;
|
|
225
|
+
dbName: string | undefined;
|
|
226
|
+
};
|
|
227
|
+
type AllowedDbClientOptions = PostgresDbClientOptions;
|
|
228
|
+
declare const getPongoDb: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: DbClientOptions) => PongoDb;
|
|
229
|
+
|
|
230
|
+
type PongoSessionOptions = {
|
|
231
|
+
explicit?: boolean;
|
|
232
|
+
defaultTransactionOptions: PongoTransactionOptions;
|
|
233
|
+
};
|
|
234
|
+
declare const pongoSession: (options?: PongoSessionOptions) => PongoSession;
|
|
235
|
+
|
|
236
|
+
declare const pongoTransaction: (options: PongoTransactionOptions) => PongoDbTransaction;
|
|
237
|
+
|
|
170
238
|
declare class FindCursor<T> {
|
|
171
239
|
private findDocumentsPromise;
|
|
172
240
|
private documents;
|
|
@@ -182,6 +250,7 @@ declare class FindCursor<T> {
|
|
|
182
250
|
declare class Db {
|
|
183
251
|
private pongoDb;
|
|
184
252
|
constructor(pongoDb: PongoDb);
|
|
253
|
+
get databaseName(): string;
|
|
185
254
|
collection<T extends Document>(collectionName: string): Collection$1<T> & {
|
|
186
255
|
handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
|
|
187
256
|
};
|
|
@@ -189,12 +258,13 @@ declare class Db {
|
|
|
189
258
|
|
|
190
259
|
declare class MongoClient {
|
|
191
260
|
private pongoClient;
|
|
192
|
-
constructor(connectionString: string, options?:
|
|
193
|
-
client?: pg.PoolClient | pg.Client;
|
|
194
|
-
});
|
|
261
|
+
constructor(connectionString: string, options?: PongoClientOptions);
|
|
195
262
|
connect(): Promise<this>;
|
|
196
263
|
close(): Promise<void>;
|
|
197
264
|
db(dbName?: string): Db;
|
|
265
|
+
startSession(_options?: ClientSessionOptions): ClientSession;
|
|
266
|
+
withSession<T = any>(_executor: WithSessionCallback<T>): Promise<T>;
|
|
267
|
+
withSession<T = any>(_options: ClientSessionOptions, _executor: WithSessionCallback<T>): Promise<T>;
|
|
198
268
|
}
|
|
199
269
|
|
|
200
270
|
declare class Collection<T extends Document> implements Collection$1<T> {
|
|
@@ -209,16 +279,16 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
209
279
|
get writeConcern(): WriteConcern | undefined;
|
|
210
280
|
get hint(): Hint | undefined;
|
|
211
281
|
set hint(v: Hint | undefined);
|
|
212
|
-
insertOne(doc: OptionalUnlessRequiredId<T>,
|
|
213
|
-
insertMany(docs: OptionalUnlessRequiredId<T>[],
|
|
282
|
+
insertOne(doc: OptionalUnlessRequiredId<T>, options?: InsertOneOptions | undefined): Promise<InsertOneResult<T>>;
|
|
283
|
+
insertMany(docs: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
|
|
214
284
|
bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
|
|
215
|
-
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>,
|
|
216
|
-
replaceOne(filter: Filter<T>, document: WithoutId$1<T>,
|
|
217
|
-
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>,
|
|
218
|
-
deleteOne(filter?: Filter<T> | undefined,
|
|
219
|
-
deleteMany(filter?: Filter<T> | undefined,
|
|
220
|
-
rename(newName: string,
|
|
221
|
-
drop(
|
|
285
|
+
updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
286
|
+
replaceOne(filter: Filter<T>, document: WithoutId$1<T>, options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
|
|
287
|
+
updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
|
|
288
|
+
deleteOne(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
289
|
+
deleteMany(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
|
|
290
|
+
rename(newName: string, options?: RenameOptions | undefined): Promise<Collection<Document>>;
|
|
291
|
+
drop(options?: DropCollectionOptions | undefined): Promise<boolean>;
|
|
222
292
|
findOne(): Promise<WithId$1<T> | null>;
|
|
223
293
|
findOne(filter: Filter<T>): Promise<WithId$1<T> | null>;
|
|
224
294
|
findOne(filter: Filter<T>, options: FindOptions<Document>): Promise<WithId$1<T> | null>;
|
|
@@ -244,8 +314,8 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
244
314
|
}): Promise<IndexDescriptionCompact>;
|
|
245
315
|
indexInformation(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
|
|
246
316
|
indexInformation(): Promise<IndexDescriptionCompact>;
|
|
247
|
-
estimatedDocumentCount(
|
|
248
|
-
countDocuments(filter?: Filter<T> | undefined,
|
|
317
|
+
estimatedDocumentCount(options?: EstimatedDocumentCountOptions | undefined): Promise<number>;
|
|
318
|
+
countDocuments(filter?: Filter<T> | undefined, options?: CountDocumentsOptions | undefined): Promise<number>;
|
|
249
319
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
250
320
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
251
321
|
distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>, options: CommandOperationOptions): Promise<Flatten<WithId$1<T>[Key]>[]>;
|
|
@@ -288,7 +358,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
|
|
|
288
358
|
watch<TLocal extends Document = T, TChange extends Document = ChangeStreamDocument<TLocal>>(_pipeline?: Document[] | undefined, _options?: ChangeStreamOptions | undefined): ChangeStream<TLocal, TChange>;
|
|
289
359
|
initializeUnorderedBulkOp(_options?: BulkWriteOptions | undefined): UnorderedBulkOperation;
|
|
290
360
|
initializeOrderedBulkOp(_options?: BulkWriteOptions | undefined): OrderedBulkOperation;
|
|
291
|
-
count(filter?: Filter<T> | undefined,
|
|
361
|
+
count(filter?: Filter<T> | undefined, options?: CountOptions | undefined): Promise<number>;
|
|
292
362
|
listSearchIndexes(options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
|
|
293
363
|
listSearchIndexes(name: string, options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
|
|
294
364
|
createSearchIndex(_description: SearchIndexDescription): Promise<string>;
|
|
@@ -303,4 +373,4 @@ type ObjectId = string & {
|
|
|
303
373
|
__brandId: 'ObjectId';
|
|
304
374
|
};
|
|
305
375
|
|
|
306
|
-
export { type $inc, type $push, type $set, type $unset,
|
|
376
|
+
export { type $inc, type $push, type $set, type $unset, type AllowedDbClientOptions, Collection, type CollectionOperationOptions, Db, type DocumentHandler, FindCursor, type HasId, MongoClient, type NonPartial, type NotPooledPongoOptions, type ObjectId, OperatorMap, type PongoClient, type PongoClientOptions, type PongoCollection, type PongoCollectionOptions, type PongoCollectionSQLBuilder, type PongoDb, type PongoDbClientOptions, type PongoDbTransaction, type PongoDeleteManyResult, type PongoDeleteResult, type PongoDocument, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoSession, type PongoSessionOptions, type PongoTransactionOptions, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type PooledPongoClientOptions, type PostgresDbClientOptions, QueryOperators, type WithId, type WithoutId, clientToDbOptions, entries, getPongoDb, hasOperators, isOperator, isPostgresClientOptions, pongoClient, pongoCollection, pongoSession, pongoTransaction, postgresDb, postgresSQLBuilder };
|