sedentary 0.0.31 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/db.js +5 -0
- package/dist/cjs/index.js +11 -0
- package/dist/es/db.js +5 -0
- package/dist/es/index.js +11 -0
- package/dist/types/db.d.ts +4 -0
- package/package.json +1 -1
package/dist/cjs/db.js
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -449,6 +449,17 @@ class Sedentary {
|
|
|
449
449
|
Object.defineProperty(ret, "foreignKeys", { value: foreignKeys });
|
|
450
450
|
Object.defineProperty(ret, "methods", { value: methods });
|
|
451
451
|
Object.assign(ret.prototype, methods);
|
|
452
|
+
const remove = this.db.remove(tableName, pk);
|
|
453
|
+
ret.prototype.remove = async function () {
|
|
454
|
+
if (!this.loaded)
|
|
455
|
+
throw new Error(`${modelName}.remove: Can't remove a never saved Entry`);
|
|
456
|
+
this.preRemove();
|
|
457
|
+
const ret = await remove.call(this);
|
|
458
|
+
if (ret)
|
|
459
|
+
this.postRemove();
|
|
460
|
+
return ret;
|
|
461
|
+
};
|
|
462
|
+
Object.defineProperty(ret.prototype.remove, "name", { value: modelName + ".remove" });
|
|
452
463
|
const save = this.db.save(tableName, attr2field, pk);
|
|
453
464
|
ret.prototype.save = async function () {
|
|
454
465
|
this.preSave();
|
package/dist/es/db.js
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -443,6 +443,17 @@ export class Sedentary {
|
|
|
443
443
|
Object.defineProperty(ret, "foreignKeys", { value: foreignKeys });
|
|
444
444
|
Object.defineProperty(ret, "methods", { value: methods });
|
|
445
445
|
Object.assign(ret.prototype, methods);
|
|
446
|
+
const remove = this.db.remove(tableName, pk);
|
|
447
|
+
ret.prototype.remove = async function () {
|
|
448
|
+
if (!this.loaded)
|
|
449
|
+
throw new Error(`${modelName}.remove: Can't remove a never saved Entry`);
|
|
450
|
+
this.preRemove();
|
|
451
|
+
const ret = await remove.call(this);
|
|
452
|
+
if (ret)
|
|
453
|
+
this.postRemove();
|
|
454
|
+
return ret;
|
|
455
|
+
};
|
|
456
|
+
Object.defineProperty(ret.prototype.remove, "name", { value: modelName + ".remove" });
|
|
446
457
|
const save = this.db.save(tableName, attr2field, pk);
|
|
447
458
|
ret.prototype.save = async function () {
|
|
448
459
|
this.preSave();
|
package/dist/types/db.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ export declare class EntryBase {
|
|
|
3
3
|
constructor(from?: Partial<EntryBase>);
|
|
4
4
|
construct(): void;
|
|
5
5
|
postLoad(): void;
|
|
6
|
+
postRemove(): void;
|
|
6
7
|
postSave(): void;
|
|
7
8
|
preLoad(): void;
|
|
9
|
+
preRemove(): void;
|
|
8
10
|
preSave(): void;
|
|
11
|
+
remove(): Promise<boolean>;
|
|
9
12
|
save(): Promise<boolean>;
|
|
10
13
|
}
|
|
11
14
|
export declare type ForeignKeyActions = "cascade" | "no action" | "restrict" | "set default" | "set null";
|
|
@@ -85,6 +88,7 @@ export declare abstract class DB<T extends Transaction> {
|
|
|
85
88
|
abstract begin(): Promise<T>;
|
|
86
89
|
abstract escape(value: Natural): string;
|
|
87
90
|
abstract load(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>, model: new () => EntryBase, table: Table): (where: string, order?: string[], tx?: Transaction, lock?: boolean) => Promise<EntryBase[]>;
|
|
91
|
+
abstract remove(tableName: string, pk: Attribute<Natural, unknown>): (this: EntryBase & Record<string, Natural>) => Promise<boolean>;
|
|
88
92
|
abstract save(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>): (this: EntryBase & Record<string, Natural>) => Promise<boolean>;
|
|
89
93
|
abstract dropConstraints(table: Table): Promise<number[]>;
|
|
90
94
|
abstract dropFields(table: Table): Promise<void>;
|
package/package.json
CHANGED