diff --git a/test/test.ts b/test/test.ts index a63a551..542f7cc 100644 --- a/test/test.ts +++ b/test/test.ts @@ -80,15 +80,27 @@ tap.test('should save the car to the db', async () => { const myCar2 = new Car('red', 'Volvo'); await myCar2.save(); - const myCar3 = new Car('red', 'Renault'); - await myCar3.save(); + + + let counter = 0; + do { + const myCar3 = new Car('red', 'Renault'); + await myCar3.save(); + counter++; + } while (counter < 2000); }); tap.test('expect to get instance of Car', async () => { - const myCars = await Car.getInstances({ - brand: 'Volvo', - }); - expect(myCars[0].color).to.equal('red'); + let counter = 0; + do { + const timeStart = Date.now(); + const myCars = await Car.getInstances({ + brand: 'Volvo', + }); + expect(myCars[0].color).to.equal('red'); + console.log(`took ${Date.now() - timeStart}`); + counter++; + } while (counter < 2000); }); tap.test('expect to get instance of Car and update it', async () => { diff --git a/ts/smartdata.classes.collection.ts b/ts/smartdata.classes.collection.ts index ea18f87..6f13d31 100644 --- a/ts/smartdata.classes.collection.ts +++ b/ts/smartdata.classes.collection.ts @@ -63,9 +63,9 @@ export class SmartdataCollection { }); if (!wantedCollection) { await this.smartdataDb.mongoDb.createCollection(this.collectionName); + console.log(`Successfully initiated Collection ${this.collectionName}`); } - this.mongoDbCollection = await this.smartdataDb.mongoDb.collection(this.collectionName); - // console.log(`Successfully initiated Collection ${this.collectionName}`); + this.mongoDbCollection = this.smartdataDb.mongoDb.collection(this.collectionName); } } diff --git a/ts/smartdata.classes.db.ts b/ts/smartdata.classes.db.ts index 0990bb0..a8aa01e 100644 --- a/ts/smartdata.classes.db.ts +++ b/ts/smartdata.classes.db.ts @@ -41,7 +41,7 @@ export class SmartdataDb { useNewUrlParser: true, useUnifiedTopology: true, maxPoolSize: 100, - maxIdleTimeMS: 10, + maxIdleTimeMS: 10 }); this.mongoDb = this.mongoDbClient.db(this.smartdataOptions.mongoDbName); this.status = 'connected';