Compare commits

..

6 Commits

Author SHA1 Message Date
3f11cbf595 4.0.21 2021-11-12 17:32:43 +01:00
cf1ec7f9eb fix(core): update 2021-11-12 17:32:43 +01:00
54060deb8f 4.0.20 2021-11-12 17:22:32 +01:00
48cffb5ac2 fix(core): update 2021-11-12 17:22:31 +01:00
8301eb79a2 4.0.19 2021-11-12 16:36:25 +01:00
ad6366a294 fix(core): update 2021-11-12 16:36:25 +01:00
8 changed files with 4998 additions and 3319 deletions

8244
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartdata", "name": "@pushrocks/smartdata",
"version": "4.0.18", "version": "4.0.21",
"private": false, "private": false,
"description": "do more with data", "description": "do more with data",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -21,27 +21,27 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartdata#README", "homepage": "https://gitlab.com/pushrocks/smartdata#README",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^4.0.20", "@pushrocks/lik": "^5.0.0",
"@pushrocks/smartlog": "^2.0.39", "@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartpromise": "^3.1.5", "@pushrocks/smartpromise": "^3.1.5",
"@pushrocks/smartstring": "^3.0.24", "@pushrocks/smartstring": "^3.0.24",
"@pushrocks/smartunique": "^3.0.3", "@pushrocks/smartunique": "^3.0.3",
"@tsclass/tsclass": "^3.0.33", "@tsclass/tsclass": "^3.0.36",
"@types/lodash": "^4.14.169", "@types/lodash": "^4.14.176",
"@types/mongodb": "^3.6.12", "@types/mongodb": "^4.0.7",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mongodb": "^3.6.6", "mongodb": "^4.1.4",
"runtime-type-checks": "0.0.4" "runtime-type-checks": "0.0.4"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.28",
"@gitzone/tstest": "^1.0.54", "@gitzone/tstest": "^1.0.60",
"@pushrocks/qenv": "^4.0.10", "@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.2.14", "@pushrocks/tapbundle": "^3.2.14",
"@types/mongodb-memory-server": "^2.3.0", "@types/mongodb-memory-server": "^2.3.0",
"@types/node": "^15.3.0", "@types/node": "^16.11.7",
"@types/shortid": "0.0.29", "@types/shortid": "0.0.29",
"mongodb-memory-server": "^6.9.6", "mongodb-memory-server": "^8.0.2",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },

View File

@ -19,23 +19,26 @@ let testDb: smartdata.SmartdataDb;
let smartdataOptions: smartdata.IMongoDescriptor; let smartdataOptions: smartdata.IMongoDescriptor;
let mongod: mongoPlugin.MongoMemoryServer; let mongod: mongoPlugin.MongoMemoryServer;
tap.test('should create a testinstance as database', async () => { tap.skip.test('should create a testinstance as database', async () => {
mongod = new mongoPlugin.MongoMemoryServer({}); mongod = await mongoPlugin.MongoMemoryServer.create();
console.log('created mongod instance'); console.log('created mongod instance');
await mongod._startUpInstance().catch((err) => {
console.log(err);
});
console.log('mongod started'); console.log('mongod started');
smartdataOptions = { smartdataOptions = {
mongoDbName: await mongod.getDbName(), mongoDbUrl: mongod.getUri(),
mongoDbPass: '',
mongoDbUrl: await mongod.getUri(),
}; };
console.log(smartdataOptions); console.log(smartdataOptions);
testDb = new smartdata.SmartdataDb(smartdataOptions); testDb = new smartdata.SmartdataDb(smartdataOptions);
await testDb.init(); await testDb.init();
}); });
tap.test('should connect to atlas', async (tools) => {
const databaseName = `test-smartdata-${smartunique.shortId()}`;
testDb = new smartdata.SmartdataDb({
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
mongoDbName: databaseName,
});
});
let easyStore: smartdata.EasyStore<{ let easyStore: smartdata.EasyStore<{
key1: string; key1: string;
key2: string; key2: string;

View File

@ -22,16 +22,11 @@ let mongod: mongoPlugin.MongoMemoryServer;
const totalCars = 2000; const totalCars = 2000;
tap.skip.test('should create a testinstance as database', async () => { tap.skip.test('should create a testinstance as database', async () => {
mongod = new mongoPlugin.MongoMemoryServer({}); mongod = await mongoPlugin.MongoMemoryServer.create();
console.log('created mongod instance'); console.log('created mongod instance');
await mongod._startUpInstance().catch((err) => {
console.log(err);
});
console.log('mongod started'); console.log('mongod started');
smartdataOptions = { smartdataOptions = {
mongoDbName: await mongod.getDbName(), mongoDbUrl: mongod.getUri(),
mongoDbPass: '',
mongoDbUrl: await mongod.getUri(),
}; };
console.log(smartdataOptions); console.log(smartdataOptions);
testDb = new smartdata.SmartdataDb(smartdataOptions); testDb = new smartdata.SmartdataDb(smartdataOptions);
@ -217,7 +212,7 @@ tap.test('should use a cursor', async () => {
// ======================================= // =======================================
// close the database connection // close the database connection
// ======================================= // =======================================
tap.test('should close the database connection', async (tools) => { tap.test('should drop the db and close the database connection', async (tools) => {
await testDb.mongoDb.dropDatabase(); await testDb.mongoDb.dropDatabase();
await testDb.close(); await testDb.close();
try { try {

View File

@ -22,16 +22,11 @@ let mongod: mongoPlugin.MongoMemoryServer;
const totalCars = 2000; const totalCars = 2000;
tap.skip.test('should create a testinstance as database', async () => { tap.skip.test('should create a testinstance as database', async () => {
mongod = new mongoPlugin.MongoMemoryServer({}); mongod = await mongoPlugin.MongoMemoryServer.create();
console.log('created mongod instance'); console.log('created mongod instance');
await mongod._startUpInstance().catch((err) => {
console.log(err);
});
console.log('mongod started'); console.log('mongod started');
smartdataOptions = { smartdataOptions = {
mongoDbName: await mongod.getDbName(), mongoDbUrl: mongod.getUri(),
mongoDbPass: '',
mongoDbUrl: await mongod.getUri(),
}; };
console.log(smartdataOptions); console.log(smartdataOptions);
testDb = new smartdata.SmartdataDb(smartdataOptions); testDb = new smartdata.SmartdataDb(smartdataOptions);

View File

@ -235,9 +235,7 @@ export class SmartdataCollection<T> {
await this.init(); await this.init();
await this.checkDoc(dbDocArg); await this.checkDoc(dbDocArg);
const identifiableObject = await dbDocArg.createIdentifiableObject(); const identifiableObject = await dbDocArg.createIdentifiableObject();
await this.mongoDbCollection.deleteOne(identifiableObject, { await this.mongoDbCollection.deleteOne(identifiableObject);
w: 1,
});
} }
/** /**

View File

@ -7,8 +7,8 @@ export class SmartdataDbCursor<T = any> {
// STATIC // STATIC
// INSTANCE // INSTANCE
public mongodbCursor: plugins.mongodb.Cursor<T>; public mongodbCursor: plugins.mongodb.FindCursor<T>;
constructor(cursorArg: plugins.mongodb.Cursor<T>) { constructor(cursorArg: plugins.mongodb.FindCursor<T>) {
this.mongodbCursor = cursorArg this.mongodbCursor = cursorArg
}; };

View File

@ -47,8 +47,6 @@ export class SmartdataDb {
.replace('<dbname>', this.smartdataOptions.mongoDbName); .replace('<dbname>', this.smartdataOptions.mongoDbName);
this.mongoDbClient = await plugins.mongodb.MongoClient.connect(finalConnectionUrl, { this.mongoDbClient = await plugins.mongodb.MongoClient.connect(finalConnectionUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
maxPoolSize: 100, maxPoolSize: 100,
maxIdleTimeMS: 10, maxIdleTimeMS: 10,
}); });
@ -78,7 +76,7 @@ export class SmartdataDb {
* @returns DbTable * @returns DbTable
*/ */
public async getSmartdataCollectionByName<T>(nameArg: string): Promise<SmartdataCollection<T>> { public async getSmartdataCollectionByName<T>(nameArg: string): Promise<SmartdataCollection<T>> {
const resultCollection = this.smartdataCollectionMap.find((dbTableArg) => { const resultCollection = await this.smartdataCollectionMap.find(async (dbTableArg) => {
return dbTableArg.collectionName === nameArg; return dbTableArg.collectionName === nameArg;
}); });
return resultCollection; return resultCollection;