apply functions

This commit is contained in:
Timo Hocker 2020-05-03 16:10:13 +02:00
parent 3af8b97258
commit ab70c46501
2 changed files with 11 additions and 14 deletions

View File

@ -55,8 +55,7 @@ export class DatabaseCrudHandler extends HttpHandler implements CrudHandler {
cm.update ();
const dm = new this.dm;
for (const key of Object.keys (body_data))
dm.set (key, cm.get (key));
dm.apply (cm);
await dm.write ();
res.status (http.status_created)
@ -76,7 +75,7 @@ export class DatabaseCrudHandler extends HttpHandler implements CrudHandler {
const dm = new this.dm (parseInt (req.headers.id as string));
const found = await dm.read ();
const cm = new this.cm (dm.object);
const cm = new this.cm (dm.get_data ());
cm.update ();
res.status (found ? http.status_ok : http.status_not_found)
@ -105,15 +104,13 @@ export class DatabaseCrudHandler extends HttpHandler implements CrudHandler {
return;
}
const cm = new this.cm (dm.object);
const cm = new this.cm (dm.get_data ());
cm.update ();
for (const key of Object.keys (body_data))
cm.set (key, body_data[key] as string|number|boolean);
cm.apply_object (body_data);
cm.update ();
for (const key of Object.keys (cm.object))
dm.set (key, cm.get (key));
dm.apply (cm);
const written = await dm.write ();

View File

@ -289,9 +289,9 @@
eslint-plugin-sort-requires-by-path "^1.0.2"
"@scode/modelling@^1.0.16":
version "1.0.16"
resolved "https://npm.scode.ovh/@scode%2fmodelling/-/modelling-1.0.16.tgz#195214d8719c7f115f4860b15e161eb10bdf56ad"
integrity sha512-gAhc1kudd3Oe38jvXih+CHI0aH4tcsiQoedHXyM0ytL6jmWpzyv8VLpwrNZCCYsjwgxV2DAK++ANEQDdEGu+Uw==
version "1.0.17"
resolved "https://npm.scode.ovh/@scode%2fmodelling/-/modelling-1.0.17.tgz#799ff3d93c588f88c17ca2162a49b0b6cbb468ba"
integrity sha512-9dc89TB0VQgWp+p8PB9n4mKXvZkD8MuwxB2lR2PGK9kBbBj8O/vwIaw+Pav+EiLLu5S/91f8rM0wThjUwfEubA==
"@sindresorhus/is@^0.14.0":
version "0.14.0"
@ -1393,9 +1393,9 @@ eslint-plugin-import@^2.20.1:
resolve "^1.12.0"
eslint-plugin-jsdoc@^24.0.0:
version "24.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-24.0.0.tgz#41c7b06d33741e41e80a8f08c82aaa58ceef2e4b"
integrity sha512-AGAc9PYpramsJGVmqtxnXBYlq+AMh+hIZdbJ52OLvyJS3f+PaT/PzuckRFOLnth2uhCDv4IjgsB3r5jUFWqUnw==
version "24.0.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-24.0.2.tgz#c679c7afac42cf872ffb1a6a246b5518b7b8eed4"
integrity sha512-tvk/jPpIP6MBVZETYnurKL/VGKzSinSbhpz1x+CzDOX20bmhRnCiexrgre4xF0WD/feg7ARKTVLCygVB3pfG5Q==
dependencies:
comment-parser "^0.7.2"
debug "^4.1.1"