@mongoosejs/studio 0.1.16 → 0.1.18
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/getCollectionInfo.js +49 -0
- package/backend/actions/Model/index.js +1 -0
- package/backend/actions/Model/updateDocument.js +3 -0
- package/backend/actions/Model/updateDocuments.js +3 -0
- package/frontend/public/app.js +954 -524
- package/frontend/public/tw.css +105 -19
- package/frontend/src/api.js +7 -1
- package/frontend/src/array-utils.js +66 -0
- package/frontend/src/chat/chat-message/chat-message.js +7 -0
- package/frontend/src/chat/chat-message-script/chat-message-script.js +21 -0
- package/frontend/src/chat/chat.js +22 -0
- package/frontend/src/clone-document/clone-document.js +14 -5
- package/frontend/src/create-dashboard/create-dashboard.js +8 -0
- package/frontend/src/create-document/create-document.js +14 -5
- package/frontend/src/dashboard/dashboard.js +9 -1
- package/frontend/src/dashboard/edit-dashboard/edit-dashboard.js +8 -0
- package/frontend/src/dashboards/dashboards.js +8 -0
- package/frontend/src/detail-array/detail-array.html +25 -3
- package/frontend/src/detail-array/detail-array.js +22 -6
- package/frontend/src/document/document.js +32 -20
- package/frontend/src/document-details/document-details.html +61 -12
- package/frontend/src/document-details/document-details.js +29 -13
- package/frontend/src/document-details/document-property/document-property.html +41 -3
- package/frontend/src/document-details/document-property/document-property.js +47 -2
- package/frontend/src/edit-array/edit-array.html +5 -2
- package/frontend/src/edit-array/edit-array.js +79 -23
- package/frontend/src/export-query-results/export-query-results.js +8 -1
- package/frontend/src/index.js +2 -1
- package/frontend/src/list-array/list-array.html +1 -1
- package/frontend/src/list-array/list-array.js +0 -2
- package/frontend/src/models/models.html +76 -8
- package/frontend/src/models/models.js +112 -1
- package/frontend/src/update-document/update-document.js +28 -27
- package/package.json +1 -1
- package/frontend/src/edit-array/edit-array.css +0 -3
- package/frontend/src/list-array/list-array.css +0 -8
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Archetype = require('archetype');
|
|
4
|
+
const authorize = require('../../authorize');
|
|
5
|
+
|
|
6
|
+
const GetCollectionInfoParams = new Archetype({
|
|
7
|
+
model: {
|
|
8
|
+
$type: 'string',
|
|
9
|
+
$required: true
|
|
10
|
+
},
|
|
11
|
+
roles: {
|
|
12
|
+
$type: ['string']
|
|
13
|
+
}
|
|
14
|
+
}).compile('GetCollectionInfoParams');
|
|
15
|
+
|
|
16
|
+
module.exports = ({ db }) => async function getCollectionInfo(params) {
|
|
17
|
+
const { model, roles } = new GetCollectionInfoParams(params);
|
|
18
|
+
|
|
19
|
+
await authorize('Model.getCollectionInfo', roles);
|
|
20
|
+
|
|
21
|
+
const Model = db.models[model];
|
|
22
|
+
if (Model == null) {
|
|
23
|
+
throw new Error(`Model ${model} not found`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const [collectionOptions, stats] = await Promise.all([
|
|
27
|
+
Model.collection.options(),
|
|
28
|
+
Model.aggregate([
|
|
29
|
+
{
|
|
30
|
+
$collStats: {
|
|
31
|
+
storageStats: {},
|
|
32
|
+
count: {}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]).then(res => res[0] ?? {})
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
info: {
|
|
40
|
+
capped: !!stats.storageStats?.capped,
|
|
41
|
+
size: stats.storageStats?.size,
|
|
42
|
+
totalIndexSize: stats.storageStats?.totalIndexSize,
|
|
43
|
+
indexCount: stats.storageStats?.nindexes,
|
|
44
|
+
documentCount: stats.storageStats?.count,
|
|
45
|
+
hasCollation: !!collectionOptions?.collation,
|
|
46
|
+
collation: collectionOptions?.collation || null
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -9,6 +9,7 @@ exports.exportQueryResults = require('./exportQueryResults');
|
|
|
9
9
|
exports.getDocument = require('./getDocument');
|
|
10
10
|
exports.getDocuments = require('./getDocuments');
|
|
11
11
|
exports.getDocumentsStream = require('./getDocumentsStream');
|
|
12
|
+
exports.getCollectionInfo = require('./getCollectionInfo');
|
|
12
13
|
exports.getIndexes = require('./getIndexes');
|
|
13
14
|
exports.listModels = require('./listModels');
|
|
14
15
|
exports.updateDocument = require('./updateDocument');
|
|
@@ -41,6 +41,9 @@ module.exports = ({ db }) => async function updateDocument(params) {
|
|
|
41
41
|
} else if (value === 'undefined') {
|
|
42
42
|
// Use $unset to remove the field for undefined values
|
|
43
43
|
unsetFields[key] = 1;
|
|
44
|
+
} else if (value === '') {
|
|
45
|
+
// Treat empty strings as undefined - unset the field
|
|
46
|
+
unsetFields[key] = 1;
|
|
44
47
|
} else {
|
|
45
48
|
setFields[key] = value;
|
|
46
49
|
}
|
|
@@ -41,6 +41,9 @@ module.exports = ({ db }) => async function updateDocuments(params) {
|
|
|
41
41
|
} else if (value === 'undefined') {
|
|
42
42
|
// Use $unset to remove the field for undefined values
|
|
43
43
|
unsetFields[key] = 1;
|
|
44
|
+
} else if (value === '') {
|
|
45
|
+
// Treat empty strings as undefined - unset the field
|
|
46
|
+
unsetFields[key] = 1;
|
|
44
47
|
} else {
|
|
45
48
|
setFields[key] = value;
|
|
46
49
|
}
|