anote-server-libs 0.6.10 → 0.6.11
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.
|
@@ -68,10 +68,10 @@ class Dao {
|
|
|
68
68
|
}
|
|
69
69
|
return Object.getOwnPropertyNames(storage).map(k => storage[k]);
|
|
70
70
|
}
|
|
71
|
-
update(instance, client) {
|
|
71
|
+
update(instance, client, on) {
|
|
72
72
|
if (instance.archivedOn)
|
|
73
73
|
return Promise.reject('Record archived!');
|
|
74
|
-
instance.updatedOn = new Date();
|
|
74
|
+
instance.updatedOn = on || new Date();
|
|
75
75
|
if (this.pool) {
|
|
76
76
|
const props = this.serialize(instance);
|
|
77
77
|
props.push(instance.id);
|
|
@@ -84,8 +84,8 @@ class Dao {
|
|
|
84
84
|
return request.query('UPDATE ' + this.table + ' SET ' + this.updateDefinition + ' WHERE id=@' + (this.nFields + 1)).then(() => instance.id);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
create(instance, client) {
|
|
88
|
-
instance.createdOn = instance.updatedOn = new Date();
|
|
87
|
+
create(instance, client, on) {
|
|
88
|
+
instance.createdOn = instance.updatedOn = on || new Date();
|
|
89
89
|
if (this.pool) {
|
|
90
90
|
const props = this.serialize(instance);
|
|
91
91
|
return (client || this.pool).query('INSERT INTO ' + this.table + '(' + this.updateDefinition.replace(/=\$\d+/g, '').replace(/=[^)]+\)/g, '') + ')'
|
|
@@ -105,10 +105,10 @@ class Dao {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
createSeveral(instances, client) {
|
|
108
|
+
createSeveral(instances, client, on) {
|
|
109
109
|
if (!instances.length)
|
|
110
110
|
return Promise.resolve([]);
|
|
111
|
-
const now = new Date();
|
|
111
|
+
const now = on || new Date();
|
|
112
112
|
instances.forEach(instance => instance.updatedOn = now);
|
|
113
113
|
const props = [].concat.apply([], instances.map(instance => this.serialize(instance)));
|
|
114
114
|
return (client || this.pool).query('INSERT INTO ' + this.table + '(' + this.updateDefinition.replace(/=\$\d+/g, '').replace(/=[^)]+\)/g, '') + ')'
|
package/package.json
CHANGED
package/.vscode/settings.json
DELETED