Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
00ec2e57c2 | |||
765356ce3d | |||
56b8581d2b | |||
37a9df9086 | |||
090fb668cd | |||
a1c807261c |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartdata",
|
"name": "@push.rocks/smartdata",
|
||||||
"version": "5.0.35",
|
"version": "5.0.38",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with data",
|
"description": "do more with data",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartdata',
|
name: '@push.rocks/smartdata',
|
||||||
version: '5.0.35',
|
version: '5.0.38',
|
||||||
description: 'do more with data'
|
description: 'do more with data'
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,13 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a unique id prefixed with the class name
|
||||||
|
*/
|
||||||
|
public static async getNewId<T = any>(this: plugins.tsclass.typeFest.Class<T>, lengthArg: number = 20) {
|
||||||
|
return `${this.name}:${plugins.smartunique.shortId(lengthArg)}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get cursor
|
* get cursor
|
||||||
* @returns
|
* @returns
|
||||||
|
@ -37,7 +37,16 @@ export class EasyStore<T> {
|
|||||||
this.nameId = nameIdArg;
|
this.nameId = nameIdArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getEasyStore() {
|
private easyStorePromise: Promise<InstanceType<typeof this.easyStoreClass>>;
|
||||||
|
private async getEasyStore(): Promise<InstanceType<typeof this.easyStoreClass>> {
|
||||||
|
if (this.easyStorePromise) {
|
||||||
|
return this.easyStorePromise;
|
||||||
|
};
|
||||||
|
|
||||||
|
// first run from here
|
||||||
|
const deferred = plugins.smartpromise.defer<InstanceType<typeof this.easyStoreClass>>();
|
||||||
|
this.easyStorePromise = deferred.promise;
|
||||||
|
|
||||||
let easyStore = await this.easyStoreClass.getInstance({
|
let easyStore = await this.easyStoreClass.getInstance({
|
||||||
nameId: this.nameId,
|
nameId: this.nameId,
|
||||||
});
|
});
|
||||||
@ -48,7 +57,8 @@ export class EasyStore<T> {
|
|||||||
easyStore.data = {};
|
easyStore.data = {};
|
||||||
await easyStore.save();
|
await easyStore.save();
|
||||||
}
|
}
|
||||||
return easyStore;
|
deferred.resolve(easyStore);
|
||||||
|
return this.easyStorePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user