@@ -5,11 +5,10 @@ import {
5
5
import assert from 'assert' ;
6
6
import console from 'console' ;
7
7
import { after , before , beforeEach , describe , it } from 'node:test' ;
8
- import { v7 as uuid } from 'uuid' ;
9
8
import {
9
+ ObjectId ,
10
10
pongoClient ,
11
11
pongoSchema ,
12
- type ObjectId ,
13
12
type PongoClient ,
14
13
type PongoCollection ,
15
14
type PongoDb ,
@@ -67,7 +66,7 @@ void describe('MongoDB Compatibility Tests', () => {
67
66
68
67
beforeEach ( ( ) => {
69
68
user = {
70
- _id : uuid ( ) ,
69
+ _id : ObjectId ( ) ,
71
70
name : 'Anita' ,
72
71
age : 25 ,
73
72
} ;
@@ -156,7 +155,7 @@ void describe('MongoDB Compatibility Tests', () => {
156
155
void describe ( 'insertMany' , ( ) => {
157
156
void it ( 'inserts a document with id' , async ( ) => {
158
157
// Given
159
- const otherUser = { ...user , _id : uuid ( ) } ;
158
+ const otherUser = { ...user , _id : ObjectId ( ) } ;
160
159
161
160
// When
162
161
const pongoInsertResult = await users . insertMany ( [ user , otherUser ] ) ;
@@ -185,7 +184,7 @@ void describe('MongoDB Compatibility Tests', () => {
185
184
const nonDefaultVersion = 495n ;
186
185
const otherUser = {
187
186
...user ,
188
- _id : uuid ( ) ,
187
+ _id : ObjectId ( ) ,
189
188
_version : nonDefaultVersion ,
190
189
} ;
191
190
// When
@@ -225,7 +224,7 @@ void describe('MongoDB Compatibility Tests', () => {
225
224
name : 'Cruella' ,
226
225
age : 40 ,
227
226
} ;
228
- const otherUser = { ...user , _id : uuid ( ) } ;
227
+ const otherUser = { ...user , _id : ObjectId ( ) } ;
229
228
// When
230
229
const pongoInsertResult = await users . insertMany ( [
231
230
userWithTheSameId ,
@@ -369,8 +368,8 @@ void describe('MongoDB Compatibility Tests', () => {
369
368
370
369
void describe ( 'updateMany' , ( ) => {
371
370
void it ( 'updates documents and expected version' , async ( ) => {
372
- const otherUser = { ...user , _id : uuid ( ) } ;
373
- await users . insertMany ( [ user , otherUser , { ...user , _id : uuid ( ) } ] ) ;
371
+ const otherUser = { ...user , _id : ObjectId ( ) } ;
372
+ await users . insertMany ( [ user , otherUser , { ...user , _id : ObjectId ( ) } ] ) ;
374
373
375
374
// When
376
375
const updateResult = await users . updateMany (
@@ -403,7 +402,7 @@ void describe('MongoDB Compatibility Tests', () => {
403
402
} ) ;
404
403
405
404
void it ( 'overrides documents version with autoincremented document version' , async ( ) => {
406
- const otherUser = { ...user , _id : uuid ( ) } ;
405
+ const otherUser = { ...user , _id : ObjectId ( ) } ;
407
406
await users . insertMany ( [ { ...user } , otherUser ] ) ;
408
407
409
408
// When
@@ -594,8 +593,8 @@ void describe('MongoDB Compatibility Tests', () => {
594
593
595
594
void describe ( 'deleteMany' , ( ) => {
596
595
void it ( 'deletes documents and expected version' , async ( ) => {
597
- const otherUser = { ...user , _id : uuid ( ) } ;
598
- await users . insertMany ( [ user , otherUser , { ...user , _id : uuid ( ) } ] ) ;
596
+ const otherUser = { ...user , _id : ObjectId ( ) } ;
597
+ await users . insertMany ( [ user , otherUser , { ...user , _id : ObjectId ( ) } ] ) ;
599
598
600
599
// When
601
600
const deleteResult = await users . deleteMany ( {
@@ -616,7 +615,7 @@ void describe('MongoDB Compatibility Tests', () => {
616
615
} ) ;
617
616
618
617
void it ( 'overrides documents version with autoincremented document version' , async ( ) => {
619
- const otherUser = { ...user , _id : uuid ( ) } ;
618
+ const otherUser = { ...user , _id : ObjectId ( ) } ;
620
619
await users . insertMany ( [ { ...user } , otherUser ] ) ;
621
620
622
621
// When
@@ -639,7 +638,7 @@ void describe('MongoDB Compatibility Tests', () => {
639
638
640
639
void describe ( 'Handle Operations' , ( ) => {
641
640
void it ( 'should NOT insert a new document if it does not exist and expected DOCUMENT_EXISTS' , async ( ) => {
642
- const nonExistingId = uuid ( ) as unknown as ObjectId ;
641
+ const nonExistingId = ObjectId ( ) as unknown as ObjectId ;
643
642
644
643
const newDoc : User = { name : 'John' , age : 25 } ;
645
644
@@ -659,7 +658,7 @@ void describe('MongoDB Compatibility Tests', () => {
659
658
} ) ;
660
659
661
660
void it ( 'should NOT insert a new document if it does not exist and expected is numeric value' , async ( ) => {
662
- const nonExistingId = uuid ( ) as unknown as ObjectId ;
661
+ const nonExistingId = ObjectId ( ) as unknown as ObjectId ;
663
662
664
663
const newDoc : User = { name : 'John' , age : 25 } ;
665
664
@@ -679,7 +678,7 @@ void describe('MongoDB Compatibility Tests', () => {
679
678
} ) ;
680
679
681
680
void it ( 'should replace an existing document when expected version matches' , async ( ) => {
682
- const existingDoc : User = { _id : uuid ( ) , name : 'John' , age : 25 } ;
681
+ const existingDoc : User = { _id : ObjectId ( ) , name : 'John' , age : 25 } ;
683
682
const updatedDoc : User = { _id : existingDoc . _id ! , name : 'John' , age : 30 } ;
684
683
685
684
const pongoInsertResult = await users . insertOne ( existingDoc ) ;
@@ -712,7 +711,7 @@ void describe('MongoDB Compatibility Tests', () => {
712
711
} ) ;
713
712
714
713
void it ( 'should NOT replace an existing document when expected DOCUMENT_DOES_NOT_EXIST' , async ( ) => {
715
- const existingDoc : User = { _id : uuid ( ) , name : 'John' , age : 25 } ;
714
+ const existingDoc : User = { _id : ObjectId ( ) , name : 'John' , age : 25 } ;
716
715
const updatedDoc : User = { _id : existingDoc . _id ! , name : 'John' , age : 30 } ;
717
716
718
717
const pongoInsertResult = await users . insertOne ( existingDoc ) ;
@@ -745,7 +744,7 @@ void describe('MongoDB Compatibility Tests', () => {
745
744
} ) ;
746
745
747
746
void it ( 'should NOT replace an existing document when expected version is mismatched ' , async ( ) => {
748
- const existingDoc : User = { _id : uuid ( ) , name : 'John' , age : 25 } ;
747
+ const existingDoc : User = { _id : ObjectId ( ) , name : 'John' , age : 25 } ;
749
748
const updatedDoc : User = { _id : existingDoc . _id ! , name : 'John' , age : 30 } ;
750
749
751
750
const pongoInsertResult = await users . insertOne ( existingDoc ) ;
0 commit comments