@@ -5,11 +5,10 @@ import {
55import assert from 'assert' ;
66import console from 'console' ;
77import { after , before , beforeEach , describe , it } from 'node:test' ;
8- import { v7 as uuid } from 'uuid' ;
98import {
9+ ObjectId ,
1010 pongoClient ,
1111 pongoSchema ,
12- type ObjectId ,
1312 type PongoClient ,
1413 type PongoCollection ,
1514 type PongoDb ,
@@ -67,7 +66,7 @@ void describe('MongoDB Compatibility Tests', () => {
6766
6867 beforeEach ( ( ) => {
6968 user = {
70- _id : uuid ( ) ,
69+ _id : ObjectId ( ) ,
7170 name : 'Anita' ,
7271 age : 25 ,
7372 } ;
@@ -156,7 +155,7 @@ void describe('MongoDB Compatibility Tests', () => {
156155 void describe ( 'insertMany' , ( ) => {
157156 void it ( 'inserts a document with id' , async ( ) => {
158157 // Given
159- const otherUser = { ...user , _id : uuid ( ) } ;
158+ const otherUser = { ...user , _id : ObjectId ( ) } ;
160159
161160 // When
162161 const pongoInsertResult = await users . insertMany ( [ user , otherUser ] ) ;
@@ -185,7 +184,7 @@ void describe('MongoDB Compatibility Tests', () => {
185184 const nonDefaultVersion = 495n ;
186185 const otherUser = {
187186 ...user ,
188- _id : uuid ( ) ,
187+ _id : ObjectId ( ) ,
189188 _version : nonDefaultVersion ,
190189 } ;
191190 // When
@@ -225,7 +224,7 @@ void describe('MongoDB Compatibility Tests', () => {
225224 name : 'Cruella' ,
226225 age : 40 ,
227226 } ;
228- const otherUser = { ...user , _id : uuid ( ) } ;
227+ const otherUser = { ...user , _id : ObjectId ( ) } ;
229228 // When
230229 const pongoInsertResult = await users . insertMany ( [
231230 userWithTheSameId ,
@@ -369,8 +368,8 @@ void describe('MongoDB Compatibility Tests', () => {
369368
370369 void describe ( 'updateMany' , ( ) => {
371370 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 ( ) } ] ) ;
374373
375374 // When
376375 const updateResult = await users . updateMany (
@@ -403,7 +402,7 @@ void describe('MongoDB Compatibility Tests', () => {
403402 } ) ;
404403
405404 void it ( 'overrides documents version with autoincremented document version' , async ( ) => {
406- const otherUser = { ...user , _id : uuid ( ) } ;
405+ const otherUser = { ...user , _id : ObjectId ( ) } ;
407406 await users . insertMany ( [ { ...user } , otherUser ] ) ;
408407
409408 // When
@@ -594,8 +593,8 @@ void describe('MongoDB Compatibility Tests', () => {
594593
595594 void describe ( 'deleteMany' , ( ) => {
596595 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 ( ) } ] ) ;
599598
600599 // When
601600 const deleteResult = await users . deleteMany ( {
@@ -616,7 +615,7 @@ void describe('MongoDB Compatibility Tests', () => {
616615 } ) ;
617616
618617 void it ( 'overrides documents version with autoincremented document version' , async ( ) => {
619- const otherUser = { ...user , _id : uuid ( ) } ;
618+ const otherUser = { ...user , _id : ObjectId ( ) } ;
620619 await users . insertMany ( [ { ...user } , otherUser ] ) ;
621620
622621 // When
@@ -639,7 +638,7 @@ void describe('MongoDB Compatibility Tests', () => {
639638
640639 void describe ( 'Handle Operations' , ( ) => {
641640 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 ;
643642
644643 const newDoc : User = { name : 'John' , age : 25 } ;
645644
@@ -659,7 +658,7 @@ void describe('MongoDB Compatibility Tests', () => {
659658 } ) ;
660659
661660 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 ;
663662
664663 const newDoc : User = { name : 'John' , age : 25 } ;
665664
@@ -679,7 +678,7 @@ void describe('MongoDB Compatibility Tests', () => {
679678 } ) ;
680679
681680 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 } ;
683682 const updatedDoc : User = { _id : existingDoc . _id ! , name : 'John' , age : 30 } ;
684683
685684 const pongoInsertResult = await users . insertOne ( existingDoc ) ;
@@ -712,7 +711,7 @@ void describe('MongoDB Compatibility Tests', () => {
712711 } ) ;
713712
714713 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 } ;
716715 const updatedDoc : User = { _id : existingDoc . _id ! , name : 'John' , age : 30 } ;
717716
718717 const pongoInsertResult = await users . insertOne ( existingDoc ) ;
@@ -745,7 +744,7 @@ void describe('MongoDB Compatibility Tests', () => {
745744 } ) ;
746745
747746 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 } ;
749748 const updatedDoc : User = { _id : existingDoc . _id ! , name : 'John' , age : 30 } ;
750749
751750 const pongoInsertResult = await users . insertOne ( existingDoc ) ;
0 commit comments