@hitchy/plugin-odem-rest 0.5.3 → 0.5.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.
@@ -87,9 +87,9 @@ module.exports = function() {
87
87
  const numOptions = optionNames.length;
88
88
 
89
89
  for ( let j = 0; j < numOptions; j++ ) {
90
- const optionName = optionNames[j].toLowerCase();
90
+ const optionName = optionNames[j];
91
91
 
92
- switch ( optionName ) {
92
+ switch ( optionName.toLowerCase() ) {
93
93
  case "type" :
94
94
  case "indexes" :
95
95
  case "indices" :
package/index.js CHANGED
@@ -630,7 +630,7 @@ module.exports = function() {
630
630
  return undefined;
631
631
  }
632
632
 
633
- const item = new Model( uuid ); // eslint-disable-line new-cap
633
+ const item = new Model( uuid, { onUnsaved: false } ); // eslint-disable-line new-cap
634
634
 
635
635
  return Promise.all( [ item.$exists, req.method === "GET" ? Promise.resolve( req.query ) : req.fetchBody() ] )
636
636
  .then( ( [ exists, record ] ) => {
@@ -641,21 +641,14 @@ module.exports = function() {
641
641
  const computedNames = Object.keys( Model.schema.computed );
642
642
  const numComputedNames = computedNames.length;
643
643
 
644
- // drop all properties
645
- for ( let i = 0; i < numPropNames; i++ ) {
646
- const propName = propNames[i];
647
- item.$properties[propName] = null;
648
- }
649
-
650
- // commit changes of properties to prevent invalid
651
- // warning/error on re-assigning
652
- item.$properties.$context.commit();
653
-
654
- // assign all posted actual properties
644
+ // update properties, drop those missing in provided record
655
645
  for ( let i = 0; i < numPropNames; i++ ) {
656
646
  const propName = propNames[i];
657
647
  const value = record[propName];
658
- if ( value != null ) {
648
+
649
+ if ( value == null ) {
650
+ item.$properties[propName] = null;
651
+ } else {
659
652
  item.$properties[propName] = value;
660
653
  }
661
654
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitchy/plugin-odem-rest",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "HTTP REST API for Hitchy's ODM",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@
22
22
  "@hitchy/plugin-odem": "^0.7.4"
23
23
  },
24
24
  "devDependencies": {
25
+ "@hitchy/types": "^0.1.1",
25
26
  "@hitchy/server-dev-tools": "^0.4.3",
26
27
  "c8": "^7.12.0",
27
28
  "eslint": "^8.24.0",