Compare commits

...

17 Commits

Author SHA1 Message Date
f799d3efa5 3.1.42 2020-09-09 02:21:16 +00:00
f74020ba96 fix(core): update 2020-09-09 02:21:15 +00:00
f6d6545ff5 3.1.41 2020-08-18 15:10:45 +00:00
85a196c8c1 fix(core): update 2020-08-18 15:10:44 +00:00
adb198af01 3.1.40 2020-08-18 13:28:01 +00:00
6dce9f3ff8 3.1.39 2020-08-18 13:27:05 +00:00
2f6a4ce3e5 fix(core): update 2020-08-18 13:27:04 +00:00
0984a1ade4 3.1.38 2020-08-18 12:53:45 +00:00
804701c96a fix(core): update 2020-08-18 12:53:44 +00:00
a3759fa484 3.1.37 2020-08-18 12:52:01 +00:00
ef38df62be fix(core): update 2020-08-18 12:52:00 +00:00
c17789e92e 3.1.36 2020-08-18 12:46:14 +00:00
0bf2ba554d fix(core): update 2020-08-18 12:46:14 +00:00
5cbf1a222a 3.1.35 2020-08-18 12:36:41 +00:00
f075530838 fix(core): update 2020-08-18 12:36:41 +00:00
efb83853fb 3.1.34 2020-08-18 12:35:16 +00:00
73300ca4d3 fix(core): update 2020-08-18 12:35:16 +00:00
7 changed files with 521 additions and 652 deletions

View File

@ -56,7 +56,6 @@ auditDevDependencies:
testStable: testStable:
stage: test stage: test
script: script:
- apt-get install lsb-core -y
- npmci npm prepare - npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install

1094
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": "3.1.33", "version": "3.1.42",
"private": false, "private": false,
"description": "do more with data", "description": "do more with data",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -25,7 +25,7 @@
"@pushrocks/smartlog": "^2.0.36", "@pushrocks/smartlog": "^2.0.36",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartstring": "^3.0.18", "@pushrocks/smartstring": "^3.0.18",
"@pushrocks/smartunique": "^3.0.3", "@tsclass/tsclass": "^3.0.24",
"@types/lodash": "^4.14.159", "@types/lodash": "^4.14.159",
"@types/mongodb": "^3.5.26", "@types/mongodb": "^3.5.26",
"lodash": "^4.17.20", "lodash": "^4.17.20",
@ -36,6 +36,7 @@
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.44", "@gitzone/tstest": "^1.0.44",
"@pushrocks/qenv": "^4.0.10", "@pushrocks/qenv": "^4.0.10",
"@pushrocks/smartunique": "^3.0.3",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/tapbundle": "^3.2.9",
"@types/mongodb-memory-server": "^2.3.0", "@types/mongodb-memory-server": "^2.3.0",
"@types/node": "^14.6.0", "@types/node": "^14.6.0",

View File

@ -5,10 +5,9 @@ const testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/');
// the tested module // the tested module
import * as smartdata from '../ts/index'; import * as smartdata from '../ts/index';
import { smartstring } from '../ts/smartdata.plugins';
import * as smartunique from '@pushrocks/smartunique';
import * as mongoPlugin from 'mongodb-memory-server'; import * as mongoPlugin from 'mongodb-memory-server';
import { smartunique } from '../ts/smartdata.plugins';
// ======================================= // =======================================
// Connecting to the database server // Connecting to the database server
@ -18,8 +17,13 @@ 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 = new mongoPlugin.MongoMemoryServer({});
console.log('created mongod instance');
await mongod._startUpInstance().catch((err) => {
console.log(err);
});
console.log('mongod started');
smartdataOptions = { smartdataOptions = {
mongoDbName: await mongod.getDbName(), mongoDbName: await mongod.getDbName(),
mongoDbPass: '', mongoDbPass: '',
@ -29,7 +33,15 @@ tap.test('should create a testinstance as database', async () => {
testDb = new smartdata.SmartdataDb(smartdataOptions); testDb = new smartdata.SmartdataDb(smartdataOptions);
}); });
tap.test('should establish a connection to the rethink Db cluster', async () => { 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,
});
});
tap.test('should establish a connection to mongod', async () => {
await testDb.init(); await testDb.init();
}); });
@ -137,7 +149,9 @@ tap.test('should store a new Truck', async () => {
// ======================================= // =======================================
tap.test('should close the database connection', async (tools) => { tap.test('should close the database connection', async (tools) => {
await testDb.close(); await testDb.close();
try {
await mongod.stop(); await mongod.stop();
} catch (e) {}
}); });
tap.start({ throwOnError: true }); tap.start({ throwOnError: true });

View File

@ -40,6 +40,8 @@ export class SmartdataDb {
this.mongoDbClient = await plugins.mongodb.MongoClient.connect(finalConnectionUrl, { this.mongoDbClient = await plugins.mongodb.MongoClient.connect(finalConnectionUrl, {
useNewUrlParser: true, useNewUrlParser: true,
useUnifiedTopology: true, useUnifiedTopology: true,
maxPoolSize: 100,
maxIdleTimeMS: 10
}); });
this.mongoDb = this.mongoDbClient.db(this.smartdataOptions.mongoDbName); this.mongoDb = this.mongoDbClient.db(this.smartdataOptions.mongoDbName);
this.status = 'connected'; this.status = 'connected';

View File

@ -89,7 +89,9 @@ export class SmartDataDbDoc<T, TImplements> {
} }
} }
public static async getInstances<T>(filterArg: Partial<T>): Promise<T[]> { public static async getInstances<T>(
filterArg: plugins.tsclass.typeFest.PartialDeep<T>
): Promise<T[]> {
const self: any = this; // fool typesystem const self: any = this; // fool typesystem
let referenceMongoDBCollection: SmartdataCollection<T>; let referenceMongoDBCollection: SmartdataCollection<T>;
@ -111,7 +113,9 @@ export class SmartDataDbDoc<T, TImplements> {
return returnArray; return returnArray;
} }
public static async getInstance<T>(filterArg: Partial<T>): Promise<T> { public static async getInstance<T>(
filterArg: plugins.tsclass.typeFest.PartialDeep<T>
): Promise<T> {
const result = await this.getInstances<T>(filterArg); const result = await this.getInstances<T>(filterArg);
if (result && result.length > 0) { if (result && result.length > 0) {
return result[0]; return result[0];

View File

@ -1,4 +1,9 @@
import * as assert from 'assert'; // tsclass scope
import * as tsclass from '@tsclass/tsclass';
export { tsclass };
// @pushrocks scope
import * as smartlog from '@pushrocks/smartlog'; import * as smartlog from '@pushrocks/smartlog';
import * as lodash from 'lodash'; import * as lodash from 'lodash';
import * as mongodb from 'mongodb'; import * as mongodb from 'mongodb';
@ -6,4 +11,4 @@ import * as smartq from '@pushrocks/smartpromise';
import * as smartstring from '@pushrocks/smartstring'; import * as smartstring from '@pushrocks/smartstring';
import * as smartunique from '@pushrocks/smartunique'; import * as smartunique from '@pushrocks/smartunique';
export { assert, smartlog, lodash, smartq, mongodb, smartstring, smartunique }; export { smartlog, lodash, smartq, mongodb, smartstring, smartunique };