fix(core): update
This commit is contained in:
parent
8e7ad5210f
commit
e58fa57525
35
package-lock.json
generated
35
package-lock.json
generated
@ -137,9 +137,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/lik": {
|
"@pushrocks/lik": {
|
||||||
"version": "3.0.17",
|
"version": "3.0.19",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.17.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.19.tgz",
|
||||||
"integrity": "sha512-Ip56GDuW/ReBPhRVIhaqosqXu12SBW1DT3GkY8hOTiF1YNdKxiaw13QOPva6KPeTffb9DTThOu352KvjMrfxRw==",
|
"integrity": "sha512-N9uTtQmTJ/iZ/V7LMCKbVx/ZAmP+b8uId0pxV9Au9T0Ulu9wcg3vNpyTQARgdWfG+tI9Qc0NHgOEa9H5mbDcDA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartdelay": "^2.0.6",
|
"@pushrocks/smartdelay": "^2.0.6",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
@ -149,16 +149,6 @@
|
|||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"symbol-tree": "^3.2.4"
|
"symbol-tree": "^3.2.4"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@pushrocks/smartdelay": {
|
|
||||||
"version": "2.0.6",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz",
|
|
||||||
"integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==",
|
|
||||||
"requires": {
|
|
||||||
"@pushrocks/smartpromise": "^3.0.6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/qenv": {
|
"@pushrocks/qenv": {
|
||||||
@ -198,7 +188,6 @@
|
|||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz",
|
||||||
"integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==",
|
"integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartpromise": "^3.0.6"
|
"@pushrocks/smartpromise": "^3.0.6"
|
||||||
}
|
}
|
||||||
@ -646,9 +635,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/mongodb": {
|
"@types/mongodb": {
|
||||||
"version": "3.3.15",
|
"version": "3.3.16",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fmongodb/-/mongodb-3.3.15.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fmongodb/-/mongodb-3.3.16.tgz",
|
||||||
"integrity": "sha512-q2dL0VEdFdE9iS0xrTP0NSgJJBFH4hBvt3beglCwU3qMWrz7dCuu/CrRjPB4+R8jLjCi/Gik2Mkd+lU0sYsZgQ==",
|
"integrity": "sha512-i1Ov36BXdp+urtPsaSvrNfCdsaVn4Ukq1m1kGyzdWB1+eg3gJ68unXU5LNmnF4EAMRFY6FXZzA7/W3NST40b8g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/bson": "*",
|
"@types/bson": "*",
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
@ -664,9 +653,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "13.7.0",
|
"version": "13.7.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.2.tgz",
|
||||||
"integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ=="
|
"integrity": "sha512-uvilvAQbdJvnSBFcKJ2td4016urcGvsiR+N4dHGU87ml8O2Vl6l+ErOi9w0kXSPiwJ1AYlIW+0pDXDWWMOiWbw=="
|
||||||
},
|
},
|
||||||
"@types/shortid": {
|
"@types/shortid": {
|
||||||
"version": "0.0.29",
|
"version": "0.0.29",
|
||||||
@ -1747,9 +1736,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
"version": "3.5.2",
|
"version": "3.5.3",
|
||||||
"resolved": "https://verdaccio.lossless.one/mongodb/-/mongodb-3.5.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/mongodb/-/mongodb-3.5.3.tgz",
|
||||||
"integrity": "sha512-Lxt4th2tK2MxmkDBR5cMik+xEnkvhwg0BC5kGcHm9RBwaNEsrIryvV5istGXOHbnif5KslMpY1FbX6YbGJ/Trg==",
|
"integrity": "sha512-II7P7A3XUdPiXRgcN96qIoRa1oesM6qLNZkzfPluNZjVkgQk3jnQwOT6/uDk4USRDTTLjNFw2vwfmbRGTA7msg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bl": "^2.2.0",
|
"bl": "^2.2.0",
|
||||||
"bson": "^1.1.1",
|
"bson": "^1.1.1",
|
||||||
|
@ -21,15 +21,15 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.17",
|
"@pushrocks/lik": "^3.0.19",
|
||||||
"@pushrocks/smartlog": "^2.0.21",
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@pushrocks/smartstring": "^3.0.18",
|
"@pushrocks/smartstring": "^3.0.18",
|
||||||
"@pushrocks/smartunique": "^3.0.1",
|
"@pushrocks/smartunique": "^3.0.1",
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.149",
|
||||||
"@types/mongodb": "^3.3.15",
|
"@types/mongodb": "^3.3.16",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"mongodb": "^3.5.2",
|
"mongodb": "^3.5.3",
|
||||||
"runtime-type-checks": "0.0.4"
|
"runtime-type-checks": "0.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"@pushrocks/qenv": "^4.0.6",
|
"@pushrocks/qenv": "^4.0.6",
|
||||||
"@pushrocks/tapbundle": "^3.2.0",
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
"@types/mongodb-memory-server": "^2.3.0",
|
"@types/mongodb-memory-server": "^2.3.0",
|
||||||
"@types/node": "^13.7.0",
|
"@types/node": "^13.7.2",
|
||||||
"@types/shortid": "0.0.29",
|
"@types/shortid": "0.0.29",
|
||||||
"mongodb-memory-server": "^6.2.4",
|
"mongodb-memory-server": "^6.2.4",
|
||||||
"tslint": "^6.0.0",
|
"tslint": "^6.0.0",
|
||||||
|
@ -44,7 +44,7 @@ tap.test('should establish a connection to the rethink Db cluster', async () =>
|
|||||||
@smartdata.Collection(() => {
|
@smartdata.Collection(() => {
|
||||||
return testDb;
|
return testDb;
|
||||||
})
|
})
|
||||||
class Car extends smartdata.SmartDataDbDoc<Car> {
|
class Car extends smartdata.SmartDataDbDoc<Car, Car> {
|
||||||
@smartdata.unI()
|
@smartdata.unI()
|
||||||
public index: string = smartunique.shortId();
|
public index: string = smartunique.shortId();
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ tap.test('should be able to delete an instance of car', async () => {
|
|||||||
@smartdata.Collection(() => {
|
@smartdata.Collection(() => {
|
||||||
return testDb;
|
return testDb;
|
||||||
})
|
})
|
||||||
class Truck extends smartdata.SmartDataDbDoc<Car> {
|
class Truck extends smartdata.SmartDataDbDoc<Car, Car> {
|
||||||
@smartdata.unI()
|
@smartdata.unI()
|
||||||
public id: string = smartunique.shortId();
|
public id: string = smartunique.shortId();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export class SmartdataCollection<T> {
|
|||||||
public smartdataDb: SmartdataDb;
|
public smartdataDb: SmartdataDb;
|
||||||
public uniqueIndexes: string[] = [];
|
public uniqueIndexes: string[] = [];
|
||||||
|
|
||||||
constructor(collectedClassArg: T & SmartDataDbDoc<T>, smartDataDbArg: SmartdataDb) {
|
constructor(collectedClassArg: T & SmartDataDbDoc<T, unknown>, smartDataDbArg: SmartdataDb) {
|
||||||
// tell the collection where it belongs
|
// tell the collection where it belongs
|
||||||
this.collectionName = collectedClassArg.name;
|
this.collectionName = collectedClassArg.name;
|
||||||
this.smartdataDb = smartDataDbArg;
|
this.smartdataDb = smartDataDbArg;
|
||||||
@ -103,7 +103,7 @@ export class SmartdataCollection<T> {
|
|||||||
/**
|
/**
|
||||||
* create an object in the database
|
* create an object in the database
|
||||||
*/
|
*/
|
||||||
public async insert(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
|
public async insert(dbDocArg: T & SmartDataDbDoc<T, unknown>): Promise<any> {
|
||||||
await this.init();
|
await this.init();
|
||||||
await this.checkDoc(dbDocArg);
|
await this.checkDoc(dbDocArg);
|
||||||
this.markUniqueIndexes(dbDocArg.uniqueIndexes);
|
this.markUniqueIndexes(dbDocArg.uniqueIndexes);
|
||||||
@ -115,7 +115,7 @@ export class SmartdataCollection<T> {
|
|||||||
/**
|
/**
|
||||||
* inserts object into the DbCollection
|
* inserts object into the DbCollection
|
||||||
*/
|
*/
|
||||||
public async update(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
|
public async update(dbDocArg: T & SmartDataDbDoc<T, unknown>): Promise<any> {
|
||||||
await this.init();
|
await this.init();
|
||||||
await this.checkDoc(dbDocArg);
|
await this.checkDoc(dbDocArg);
|
||||||
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
||||||
@ -134,7 +134,7 @@ export class SmartdataCollection<T> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async delete(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
|
public async delete(dbDocArg: T & SmartDataDbDoc<T, unknown>): Promise<any> {
|
||||||
await this.init();
|
await this.init();
|
||||||
await this.checkDoc(dbDocArg);
|
await this.checkDoc(dbDocArg);
|
||||||
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
||||||
|
@ -11,7 +11,7 @@ export type TDocCreation = 'db' | 'new' | 'mixed';
|
|||||||
* saveable - saveable decorator to be used on class properties
|
* saveable - saveable decorator to be used on class properties
|
||||||
*/
|
*/
|
||||||
export function svDb() {
|
export function svDb() {
|
||||||
return (target: SmartDataDbDoc<any>, key: string) => {
|
return (target: SmartDataDbDoc<unknown, unknown>, key: string) => {
|
||||||
console.log(`called svDb() on ${key}`);
|
console.log(`called svDb() on ${key}`);
|
||||||
if (!target.saveableProperties) {
|
if (!target.saveableProperties) {
|
||||||
target.saveableProperties = [];
|
target.saveableProperties = [];
|
||||||
@ -24,7 +24,7 @@ export function svDb() {
|
|||||||
* unique index - decorator to mark a unique index
|
* unique index - decorator to mark a unique index
|
||||||
*/
|
*/
|
||||||
export function unI() {
|
export function unI() {
|
||||||
return (target: SmartDataDbDoc<any>, key: string) => {
|
return (target: SmartDataDbDoc<unknown, unknown>, key: string) => {
|
||||||
console.log('called unI');
|
console.log('called unI');
|
||||||
|
|
||||||
// mark the index as unique
|
// mark the index as unique
|
||||||
@ -41,7 +41,7 @@ export function unI() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SmartDataDbDoc<T> {
|
export class SmartDataDbDoc<T, TImplements> {
|
||||||
/**
|
/**
|
||||||
* the collection object an Doc belongs to
|
* the collection object an Doc belongs to
|
||||||
*/
|
*/
|
||||||
@ -150,9 +150,9 @@ export class SmartDataDbDoc<T> {
|
|||||||
* also store any referenced objects to DB
|
* also store any referenced objects to DB
|
||||||
* better for data consistency
|
* better for data consistency
|
||||||
*/
|
*/
|
||||||
public saveDeep(savedMapArg: Objectmap<SmartDataDbDoc<any>> = null) {
|
public saveDeep(savedMapArg: Objectmap<SmartDataDbDoc<any, any>> = null) {
|
||||||
if (!savedMapArg) {
|
if (!savedMapArg) {
|
||||||
savedMapArg = new Objectmap<SmartDataDbDoc<any>>();
|
savedMapArg = new Objectmap<SmartDataDbDoc<any, any>>();
|
||||||
}
|
}
|
||||||
savedMapArg.add(this);
|
savedMapArg.add(this);
|
||||||
this.save();
|
this.save();
|
||||||
@ -167,12 +167,12 @@ export class SmartDataDbDoc<T> {
|
|||||||
/**
|
/**
|
||||||
* creates a saveable object so the instance can be persisted as json in the database
|
* creates a saveable object so the instance can be persisted as json in the database
|
||||||
*/
|
*/
|
||||||
public async createSavableObject() {
|
public async createSavableObject(): Promise<TImplements> {
|
||||||
const saveableObject: any = {}; // is not exposed to outside, so any is ok here
|
const saveableObject: unknown = {}; // is not exposed to outside, so any is ok here
|
||||||
for (const propertyNameString of this.saveableProperties) {
|
for (const propertyNameString of this.saveableProperties) {
|
||||||
saveableObject[propertyNameString] = this[propertyNameString];
|
saveableObject[propertyNameString] = this[propertyNameString];
|
||||||
}
|
}
|
||||||
return saveableObject;
|
return saveableObject as TImplements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user