@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.
- package/backend/actions/Model/updateDocument.js +7 -9
- package/eslint.config.js +1 -0
- package/frontend/public/app.js +292 -76
- package/frontend/public/tw.css +4 -0
- package/frontend/src/_util/baseComponent.js +19 -0
- package/frontend/src/_util/deepEqual.js +53 -0
- package/frontend/src/_util/document-search-autocomplete.js +4 -4
- package/frontend/src/array-utils.js +1 -0
- package/frontend/src/dashboard/dashboard.js +22 -17
- package/frontend/src/document/confirm-changes/confirm-changes.js +11 -1
- package/frontend/src/document/document.html +1 -1
- package/frontend/src/document/document.js +16 -1
- package/frontend/src/document-details/document-property/document-property.html +1 -1
- package/frontend/src/document-details/document-property/document-property.js +15 -1
- package/frontend/src/edit-boolean/edit-boolean.js +1 -9
- package/frontend/src/index.js +9 -2
- package/frontend/src/mothership.js +11 -2
- package/package.json +5 -3
|
@@ -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 === '
|
|
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 {
|