Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f11cbf595 | |||
cf1ec7f9eb | |||
54060deb8f | |||
48cffb5ac2 |
8244
package-lock.json
generated
8244
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdata",
|
"name": "@pushrocks/smartdata",
|
||||||
"version": "4.0.19",
|
"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"
|
||||||
},
|
},
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
@ -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,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Reference in New Issue
Block a user