fix(core): update

This commit is contained in:
Philipp Kunz 2021-10-16 21:17:02 +02:00
parent 7cbd0bd99b
commit 7a4d557724
10 changed files with 33 additions and 32 deletions

View File

@ -12,6 +12,10 @@ stages:
- release
- metadata
before_script:
- apt-get update && apt-get install -y libcurl3 libssl-dev openssl libssl1.0.0 mongodb
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
@ -36,6 +40,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

View File

@ -60,4 +60,4 @@
"browserslist": [
"last 1 chrome versions"
]
}
}

View File

@ -90,7 +90,7 @@ class MyObject extends smartdata.DbDoc<MyObject /* ,[an optional interface to im
const localObject = new MyObject({
property1: 'hi',
property2: {
deep: 3
deep: 3,
},
});
await localObject.save(); // saves the object to the database
@ -102,9 +102,9 @@ const myInstance = await MyObject.getInstance({
property1: 'hi',
property2: {
deep: {
$gt: 2
} as any
}
$gt: 2,
} as any,
},
}); // outputs a new instance of MyObject with the values from db assigned
```

View File

@ -19,7 +19,6 @@ let testDb: smartdata.SmartdataDb;
let smartdataOptions: smartdata.IMongoDescriptor;
let mongod: mongoPlugin.MongoMemoryServer;
tap.test('should create a testinstance as database', async () => {
mongod = new mongoPlugin.MongoMemoryServer({});
console.log('created mongod instance');
@ -47,14 +46,14 @@ tap.test('should create an easystore', async () => {
await easyStore.writeKey('key1', 'hello');
const retrievedKey = await easyStore.readKey('key1');
expect(retrievedKey).to.equal('hello');
})
});
tap.test('close', async () => {
testDb.close();
mongod.stop();
setTimeout(() => {
process.exit(0);
}, 1000)
})
}, 1000);
});
tap.start();
tap.start();

View File

@ -134,7 +134,7 @@ tap.test('expect to get instance of Car with deep match', async () => {
const timeStart = Date.now();
const myCars2 = await Car.getInstances({
deepData: {
sodeep: 'yes'
sodeep: 'yes',
},
});
if (counter % 10 === 0) {
@ -207,7 +207,7 @@ tap.test('should store a new Truck', async () => {
console.log(myTruck2);
});
tap.test('should ', async () => {})
tap.test('should ', async () => {});
// =======================================
// close the database connection

View File

@ -80,7 +80,7 @@ class Car extends smartdata.SmartDataDbDoc<Car, Car> {
}
const createCarClass = (dbArg: smartdata.SmartdataDb) => {
smartdata.setDefaultManagerForDoc({db: dbArg}, Car);
smartdata.setDefaultManagerForDoc({ db: dbArg }, Car);
return Car;
};
@ -92,9 +92,9 @@ tap.test('should produce a car', async () => {
tap.test('should get a car', async () => {
const car = Car.getInstance({
color: 'red'
})
})
color: 'red',
});
});
// =======================================
// close the database connection

View File

@ -42,19 +42,19 @@ export function Collection(dbArg: SmartdataDb | TDelayed<SmartdataDb>) {
}
export interface IManager {
db: SmartdataDb
db: SmartdataDb;
}
export const setDefaultManagerForDoc = <T>(managerArg: IManager, dbDocArg: T): T => {
export const setDefaultManagerForDoc = <T>(managerArg: IManager, dbDocArg: T): T => {
(dbDocArg as any).prototype.defaultManager = managerArg;
return dbDocArg;
}
};
/**
* This is a decorator that will tell the decorated class what dbTable to use
* @param dbArg
*/
export function Manager<TManager extends IManager>(managerArg?: TManager | TDelayed<TManager>) {
export function Manager<TManager extends IManager>(managerArg?: TManager | TDelayed<TManager>) {
return function classDecorator<T extends { new (...args: any[]): any }>(constructor: T) {
return class extends constructor {
public static get collection() {
@ -62,7 +62,7 @@ export const setDefaultManagerForDoc = <T>(managerArg: IManager, dbDocArg: T):
if (!managerArg) {
dbArg = this.prototype.defaultManager.db;
} else if (managerArg['db']) {
dbArg = (managerArg as TManager).db
dbArg = (managerArg as TManager).db;
} else {
dbArg = (managerArg as TDelayed<TManager>)().db;
}
@ -75,7 +75,7 @@ export const setDefaultManagerForDoc = <T>(managerArg: IManager, dbDocArg: T):
//process.exit(0)
dbArg = this.defaultManager.db;
} else if (managerArg['db']) {
dbArg = (managerArg as TManager).db
dbArg = (managerArg as TManager).db;
} else {
dbArg = (managerArg as TDelayed<TManager>)().db;
}
@ -84,7 +84,7 @@ export const setDefaultManagerForDoc = <T>(managerArg: IManager, dbDocArg: T):
public static get manager() {
let manager: TManager;
if (managerArg['db']) {
manager = (managerArg as TManager);
manager = managerArg as TManager;
} else {
manager = (managerArg as TDelayed<TManager>)();
}
@ -93,7 +93,7 @@ export const setDefaultManagerForDoc = <T>(managerArg: IManager, dbDocArg: T):
public get manager() {
let manager: TManager;
if (managerArg['db']) {
manager = (managerArg as TManager);
manager = managerArg as TManager;
} else {
manager = (managerArg as TDelayed<TManager>)();
}

View File

@ -5,10 +5,7 @@ import { SmartdataDb } from './smartdata.classes.db';
export class CollectionFactory {
public collections: { [key: string]: SmartdataCollection<any> } = {};
public getCollection = (
nameArg: string,
dbArg: SmartdataDb
): SmartdataCollection<any> => {
public getCollection = (nameArg: string, dbArg: SmartdataDb): SmartdataCollection<any> => {
if (!this.collections[nameArg]) {
this.collections[nameArg] = (() => {
if (dbArg instanceof SmartdataDb) {

View File

@ -98,11 +98,11 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
}
for (const key of Object.keys(filterArg2)) {
convertFilterArgument(`${keyPathArg}.${key}`, filterArg2[key]);
}
}
} else {
convertedFilter[keyPathArg] = filterArg2
convertedFilter[keyPathArg] = filterArg2;
}
}
};
for (const key of Object.keys(filterArg)) {
convertFilterArgument(key, filterArg[key]);
}

View File

@ -30,7 +30,7 @@ export class EasyStore<T> {
public async getEasyStore() {
let easyStore = await this.easyStoreClass.getInstance({
nameId: this.nameId
nameId: this.nameId,
});
if (!easyStore) {