@mongoosejs/studio 0.2.1 → 0.2.3

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.
@@ -16,13 +16,16 @@ const UpdateDocumentsParams = new Archetype({
16
16
  $type: Object,
17
17
  $required: true
18
18
  },
19
+ unset: {
20
+ $type: Object
21
+ },
19
22
  roles: {
20
23
  $type: ['string']
21
24
  }
22
25
  }).compile('UpdateDocumentsParams');
23
26
 
24
27
  module.exports = ({ db }) => async function updateDocument(params) {
25
- const { model, _id, update, roles } = new UpdateDocumentsParams(params);
28
+ const { model, _id, update, unset, roles } = new UpdateDocumentsParams(params);
26
29
 
27
30
  await authorize('Model.updateDocument', roles);
28
31
 
@@ -32,16 +35,11 @@ module.exports = ({ db }) => async function updateDocument(params) {
32
35
  }
33
36
 
34
37
  const setFields = {};
35
- const unsetFields = {};
36
-
38
+ const unsetFields = unset || {};
39
+
37
40
  if (Object.keys(update).length > 0) {
38
41
  Object.entries(update).forEach(([key, value]) => {
39
- if (value === 'null') {
40
- setFields[key] = null;
41
- } else if (value === 'undefined') {
42
- // Use $unset to remove the field for undefined values
43
- unsetFields[key] = 1;
44
- } else if (value === '') {
42
+ if (value === '') {
45
43
  // Treat empty strings as undefined - unset the field
46
44
  unsetFields[key] = 1;
47
45
  } else {
package/eslint.config.js CHANGED
@@ -33,6 +33,7 @@ module.exports = defineConfig([
33
33
  CodeMirror: true,
34
34
  Chart: true,
35
35
  URLSearchParams: true,
36
+ URL: true,
36
37
  fetch: true,
37
38
  __dirname: true,
38
39
  process: true,