Comparing version 0.0.31 to 0.0.32
@@ -16,5 +16,10 @@ "use strict"; | ||
postLoad() { } | ||
postRemove() { } | ||
postSave() { } | ||
preLoad() { } | ||
preRemove() { } | ||
preSave() { } | ||
async remove() { | ||
return false; | ||
} | ||
async save() { | ||
@@ -21,0 +26,0 @@ return false; |
@@ -452,2 +452,13 @@ "use strict"; | ||
Object.assign(ret.prototype, methods); | ||
const remove = this.db.remove(tableName, pk); | ||
ret.prototype.remove = async function () { | ||
if (!this.loaded) | ||
throw new Error(`${modelName}.remove: Can't remove a never saved Entry`); | ||
this.preRemove(); | ||
const ret = await remove.call(this); | ||
if (ret) | ||
this.postRemove(); | ||
return ret; | ||
}; | ||
Object.defineProperty(ret.prototype.remove, "name", { value: modelName + ".remove" }); | ||
const save = this.db.save(tableName, attr2field, pk); | ||
@@ -454,0 +465,0 @@ ret.prototype.save = async function () { |
@@ -13,5 +13,10 @@ export class EntryBase { | ||
postLoad() { } | ||
postRemove() { } | ||
postSave() { } | ||
preLoad() { } | ||
preRemove() { } | ||
preSave() { } | ||
async remove() { | ||
return false; | ||
} | ||
async save() { | ||
@@ -18,0 +23,0 @@ return false; |
@@ -446,2 +446,13 @@ import { Attribute, EntryBase, Table, Transaction, Type } from "./db"; | ||
Object.assign(ret.prototype, methods); | ||
const remove = this.db.remove(tableName, pk); | ||
ret.prototype.remove = async function () { | ||
if (!this.loaded) | ||
throw new Error(`${modelName}.remove: Can't remove a never saved Entry`); | ||
this.preRemove(); | ||
const ret = await remove.call(this); | ||
if (ret) | ||
this.postRemove(); | ||
return ret; | ||
}; | ||
Object.defineProperty(ret.prototype.remove, "name", { value: modelName + ".remove" }); | ||
const save = this.db.save(tableName, attr2field, pk); | ||
@@ -448,0 +459,0 @@ ret.prototype.save = async function () { |
@@ -6,5 +6,8 @@ export declare type Natural = Date | Record<string, unknown> | boolean | number | string | null; | ||
postLoad(): void; | ||
postRemove(): void; | ||
postSave(): void; | ||
preLoad(): void; | ||
preRemove(): void; | ||
preSave(): void; | ||
remove(): Promise<boolean>; | ||
save(): Promise<boolean>; | ||
@@ -89,2 +92,3 @@ } | ||
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[]>; | ||
abstract remove(tableName: string, pk: Attribute<Natural, unknown>): (this: EntryBase & Record<string, Natural>) => Promise<boolean>; | ||
abstract save(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>): (this: EntryBase & Record<string, Natural>) => Promise<boolean>; | ||
@@ -91,0 +95,0 @@ abstract dropConstraints(table: Table): Promise<number[]>; |
@@ -82,3 +82,3 @@ { | ||
"types": "./dist/types/index.d.ts", | ||
"version": "0.0.31" | ||
"version": "0.0.32" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81143
1418