@@ -38,6 +38,7 @@ import {
38
38
type ReplaceOneOptions ,
39
39
type UpdateManyOptions ,
40
40
type UpdateOneOptions ,
41
+ type WithIdAndVersion ,
41
42
type WithoutId ,
42
43
type WithVersion ,
43
44
} from '..' ;
@@ -282,16 +283,16 @@ export const pongoCollection = <
282
283
findOne : async (
283
284
filter ?: PongoFilter < T > ,
284
285
options ?: CollectionOperationOptions ,
285
- ) : Promise < T | null > => {
286
+ ) : Promise < WithIdAndVersion < T > | null > => {
286
287
await ensureCollectionCreated ( options ) ;
287
288
288
289
const result = await query ( SqlFor . findOne ( filter ?? { } ) , options ) ;
289
- return ( result . rows [ 0 ] ?. data ?? null ) as T | null ;
290
+ return ( result . rows [ 0 ] ?. data ?? null ) as WithIdAndVersion < T > | null ;
290
291
} ,
291
292
findOneAndDelete : async (
292
293
filter : PongoFilter < T > ,
293
294
options ?: DeleteOneOptions ,
294
- ) : Promise < T | null > => {
295
+ ) : Promise < WithIdAndVersion < T > | null > => {
295
296
await ensureCollectionCreated ( options ) ;
296
297
297
298
const existingDoc = await collection . findOne ( filter , options ) ;
@@ -305,7 +306,7 @@ export const pongoCollection = <
305
306
filter : PongoFilter < T > ,
306
307
replacement : WithoutId < T > ,
307
308
options ?: ReplaceOneOptions ,
308
- ) : Promise < T | null > => {
309
+ ) : Promise < WithIdAndVersion < T > | null > => {
309
310
await ensureCollectionCreated ( options ) ;
310
311
311
312
const existingDoc = await collection . findOne ( filter , options ) ;
@@ -320,7 +321,7 @@ export const pongoCollection = <
320
321
filter : PongoFilter < T > ,
321
322
update : PongoUpdate < T > ,
322
323
options ?: UpdateOneOptions ,
323
- ) : Promise < T | null > => {
324
+ ) : Promise < WithIdAndVersion < T > | null > => {
324
325
await ensureCollectionCreated ( options ) ;
325
326
326
327
const existingDoc = await collection . findOne ( filter , options ) ;
@@ -427,11 +428,11 @@ export const pongoCollection = <
427
428
find : async (
428
429
filter ?: PongoFilter < T > ,
429
430
options ?: CollectionOperationOptions ,
430
- ) : Promise < T [ ] > => {
431
+ ) : Promise < WithIdAndVersion < T > [ ] > => {
431
432
await ensureCollectionCreated ( options ) ;
432
433
433
434
const result = await query ( SqlFor . find ( filter ?? { } ) ) ;
434
- return result . rows . map ( ( row ) => row . data as T ) ;
435
+ return result . rows . map ( ( row ) => row . data as WithIdAndVersion < T > ) ;
435
436
} ,
436
437
countDocuments : async (
437
438
filter ?: PongoFilter < T > ,
0 commit comments