@mongoosejs/studio 0.0.41 → 0.0.44
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.
|
@@ -25,8 +25,15 @@ module.exports = ({ db }) => async function updateDocument(params) {
|
|
|
25
25
|
throw new Error(`Model ${model} not found`);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
let processedUpdate = update;
|
|
29
|
+
if (Object.keys(update).length > 0) {
|
|
30
|
+
processedUpdate = Object.fromEntries(
|
|
31
|
+
Object.entries(update).map(([key, value]) => [key, value === 'null' ? null : value === 'undefined' ? undefined : value])
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
const doc = await Model.
|
|
29
|
-
findByIdAndUpdate(_id,
|
|
36
|
+
findByIdAndUpdate(_id, processedUpdate, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true, runValidators: false });
|
|
30
37
|
|
|
31
38
|
return { doc };
|
|
32
39
|
};
|
package/backend/next.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Backend = require('./');
|
|
4
|
+
const { toNetlifyFunction } = require('extrovert');
|
|
4
5
|
|
|
5
6
|
module.exports = function next() {
|
|
6
7
|
const backend = Backend();
|
|
7
8
|
|
|
8
|
-
return
|
|
9
|
-
const params = { ...req.body };
|
|
9
|
+
return function wrappedNextJSFunction(req, res) {
|
|
10
10
|
const actionName = params?.action;
|
|
11
11
|
if (typeof actionName !== 'string') {
|
|
12
12
|
throw new Error('No action specified');
|
|
@@ -23,6 +23,9 @@ module.exports = function next() {
|
|
|
23
23
|
throw new Error(`Action ${actionName} not found`);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const params = { ...req.query, ...req.body, ...req.params };
|
|
27
|
+
return actionFn(params)
|
|
28
|
+
.then(result => res.status(200).json(result))
|
|
29
|
+
.catch(error => res.status(500).json({ message: error.message }));
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
<div>
|
|
2
|
-
<input
|
|
3
|
-
|
|
2
|
+
<input
|
|
3
|
+
v-if="dateSelection == 'picker'"
|
|
4
|
+
class="w-64 h-8 border border-gray-300 outline-0"
|
|
5
|
+
type="datetime-local"
|
|
6
|
+
:value="valueAsLocalString"
|
|
7
|
+
@input="$emit('input', $event.target.value)">
|
|
8
|
+
<input
|
|
9
|
+
v-if="dateSelection == 'iso'"
|
|
10
|
+
type="text"
|
|
11
|
+
class="w-64 h-8 border border-gray-300 outline-0"
|
|
12
|
+
:value="valueAsISOString"
|
|
13
|
+
@input="updateFromISO">
|
|
4
14
|
</div>
|
|
@@ -9,6 +9,24 @@ module.exports = app => app.component('edit-date', {
|
|
|
9
9
|
data: () => ({
|
|
10
10
|
inputType: ''
|
|
11
11
|
}),
|
|
12
|
+
methods: {
|
|
13
|
+
updateFromISO($event) {
|
|
14
|
+
const value = $event.target.value;
|
|
15
|
+
if (value == null) {
|
|
16
|
+
return this.$emit('input', $event.target.value);
|
|
17
|
+
}
|
|
18
|
+
if (value === 'null') {
|
|
19
|
+
return this.$emit('input', null);
|
|
20
|
+
}
|
|
21
|
+
if (value === 'undefined') {
|
|
22
|
+
return this.$emit('input', undefined);
|
|
23
|
+
}
|
|
24
|
+
const valueAsDate = new Date(value);
|
|
25
|
+
if (!isNaN(valueAsDate.valueOf())) {
|
|
26
|
+
this.$emit('input', $event.target.value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
12
30
|
computed: {
|
|
13
31
|
valueAsLocalString() {
|
|
14
32
|
if (this.value == null) {
|
|
@@ -29,7 +47,7 @@ module.exports = app => app.component('edit-date', {
|
|
|
29
47
|
},
|
|
30
48
|
valueAsISOString() {
|
|
31
49
|
if (this.value == null) {
|
|
32
|
-
return this.value;
|
|
50
|
+
return '' + this.value;
|
|
33
51
|
}
|
|
34
52
|
const date = new Date(this.value);
|
|
35
53
|
return date.toISOString();
|
package/frontend/src/index.js
CHANGED
|
@@ -53,7 +53,7 @@ app.component('app-component', {
|
|
|
53
53
|
`,
|
|
54
54
|
errorCaptured(err) {
|
|
55
55
|
vanillatoasts.create({
|
|
56
|
-
title: `Error: ${err.message}`,
|
|
56
|
+
title: `Error: ${err?.response?.data?.message || err.message}`,
|
|
57
57
|
icon: 'images/failure.jpg',
|
|
58
58
|
timeout: 10000,
|
|
59
59
|
positionClass: 'bottomRight'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mongoosejs/studio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"archetype": "0.13.0",
|
|
6
6
|
"csv-stringify": "6.3.0",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"bson": "^5.5.1 || 6.x",
|
|
17
17
|
"express": "4.x",
|
|
18
|
-
"mongoose": "7.x || 8.
|
|
18
|
+
"mongoose": "7.x || 8.x"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"axios": "1.2.2",
|