anote-server-libs 0.2.4 → 0.2.5
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.
|
@@ -74,13 +74,6 @@ class Dao {
|
|
|
74
74
|
return request.query('UPDATE ' + this.table + ' SET ' + this.updateDefinition + ' WHERE id=@' + (this.nFields + 1)).then(() => instance.id);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
replace(instance, client) {
|
|
78
|
-
if (instance.archivedOn)
|
|
79
|
-
return Promise.reject('Record archived!');
|
|
80
|
-
return this.create({ ...instance, replaced_id: instance.id }, client).then(id => {
|
|
81
|
-
return this.archive(instance.id, id, client).then(() => id);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
77
|
create(instance, client) {
|
|
85
78
|
instance.createdOn = instance.updatedOn = new Date();
|
|
86
79
|
if (this.pool) {
|
|
@@ -225,6 +218,13 @@ class ModelDao extends Dao {
|
|
|
225
218
|
return request.query('UPDATE ' + this.table + ' SET "archivedOn"=now(),replaced_by_id=@1 WHERE id=@2');
|
|
226
219
|
}
|
|
227
220
|
}
|
|
221
|
+
replace(instance, client) {
|
|
222
|
+
if (instance.archivedOn)
|
|
223
|
+
return Promise.reject('Record archived!');
|
|
224
|
+
return this.create({ ...instance, replaced_id: instance.id }, client).then(id => {
|
|
225
|
+
return this.archive(instance.id, id, client).then(() => id);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
228
|
delete(id, client) {
|
|
229
229
|
if (this.pool) {
|
|
230
230
|
return client.query('DELETE FROM ' + this.table + ' WHERE id=$1', [id]);
|
|
@@ -96,13 +96,6 @@ export abstract class Dao<R, T extends Model<R>> implements ModelRepr {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
replace(this: ModelDao<R, T>, instance: T, client: ClientBase | Transaction): Promise<R> {
|
|
100
|
-
if((<any>instance).archivedOn) return Promise.reject('Record archived!');
|
|
101
|
-
return this.create({...instance, replaced_id: instance.id}, client).then(id => {
|
|
102
|
-
return this.archive(instance.id, id, client).then(() => id);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
99
|
create(instance: T, client?: ClientBase | Transaction): Promise<R> {
|
|
107
100
|
(<any>instance).createdOn = instance.updatedOn = new Date();
|
|
108
101
|
if(this.pool) {
|
|
@@ -247,6 +240,13 @@ export abstract class ModelDao<R, T extends Model<R>> extends Dao<R, T> {
|
|
|
247
240
|
}
|
|
248
241
|
}
|
|
249
242
|
|
|
243
|
+
replace(instance: T, client: ClientBase | Transaction): Promise<R> {
|
|
244
|
+
if((<any>instance).archivedOn) return Promise.reject('Record archived!');
|
|
245
|
+
return this.create({...instance, replaced_id: instance.id}, client).then(id => {
|
|
246
|
+
return this.archive(instance.id, id, client).then(() => id);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
250
|
delete(id: R, client: ClientBase | Transaction): Promise<any> {
|
|
251
251
|
if(this.pool) {
|
|
252
252
|
return (<ClientBase>client).query('DELETE FROM ' + this.table + ' WHERE id=$1', [id]);
|