@mongoosejs/studio 0.0.21 → 0.0.22
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/Dashboard/getDashboards.js +10 -0
- package/backend/actions/Dashboard/index.js +3 -0
- package/backend/actions/Model/createDocument.js +28 -0
- package/backend/actions/Model/getDocuments.js +2 -1
- package/backend/actions/Model/index.js +1 -0
- package/backend/actions/Model/listModels.js +3 -1
- package/backend/actions/Model/updateDocument.js +1 -1
- package/backend/actions/index.js +1 -0
- package/backend/db/dashboardSchema.js +16 -0
- package/backend/index.js +5 -1
- package/frontend/public/app.js +30567 -467
- package/frontend/public/images/json.svg +2 -0
- package/frontend/public/images/table.svg +1 -0
- package/frontend/public/tw.css +197 -22
- package/frontend/src/api.js +16 -0
- package/frontend/src/create-document/create-document.css +0 -0
- package/frontend/src/create-document/create-document.html +6 -0
- package/frontend/src/create-document/create-document.js +75 -0
- package/frontend/src/dashboard/dashboard.html +8 -0
- package/frontend/src/dashboard/dashboard.js +22 -0
- package/frontend/src/dashboard-details/dashboard-details.html +8 -0
- package/frontend/src/dashboard-details/dashboard-details.js +10 -0
- package/frontend/src/document/document.html +2 -1
- package/frontend/src/document/document.js +3 -1
- package/frontend/src/edit-date/edit-date.html +18 -1
- package/frontend/src/edit-date/edit-date.js +12 -0
- package/frontend/src/index.js +4 -0
- package/frontend/src/list-json/list-json.css +3 -0
- package/frontend/src/list-json/list-json.html +4 -0
- package/frontend/src/list-json/list-json.js +40 -0
- package/frontend/src/models/models.css +2 -6
- package/frontend/src/models/models.html +42 -10
- package/frontend/src/models/models.js +26 -1
- package/frontend/src/navbar/navbar.css +9 -0
- package/frontend/src/navbar/navbar.html +11 -3
- package/frontend/src/navbar/navbar.js +6 -1
- package/frontend/src/routes.js +5 -0
- package/package.json +7 -2
- package/tailwind.config.js +27 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Archetype = require('archetype');
|
|
4
|
+
const { EJSON } = require('bson');
|
|
5
|
+
|
|
6
|
+
const CreateDocumentParams = new Archetype({
|
|
7
|
+
model: {
|
|
8
|
+
$type: 'string',
|
|
9
|
+
$required: true
|
|
10
|
+
},
|
|
11
|
+
data: {
|
|
12
|
+
$type: Archetype.Any,
|
|
13
|
+
$required: true
|
|
14
|
+
}
|
|
15
|
+
}).compile('CreateDocumentParams');
|
|
16
|
+
|
|
17
|
+
module.exports = ({ db }) => async function CreateDocument(params) {
|
|
18
|
+
const { model, data } = new CreateDocumentParams(params);
|
|
19
|
+
|
|
20
|
+
const Model = db.models[model];
|
|
21
|
+
if (Model == null) {
|
|
22
|
+
throw new Error(`Model ${model} not found`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const doc = await Model.create(EJSON.deserialize(data));
|
|
26
|
+
|
|
27
|
+
return { doc };
|
|
28
|
+
};
|
|
@@ -56,7 +56,8 @@ module.exports = ({ db }) => async function getDocuments(params) {
|
|
|
56
56
|
schemaPaths[path] = {
|
|
57
57
|
instance: Model.schema.paths[path].instance,
|
|
58
58
|
path,
|
|
59
|
-
ref: Model.schema.paths[path].options?.ref
|
|
59
|
+
ref: Model.schema.paths[path].options?.ref,
|
|
60
|
+
required: Model.schema.paths[path].options?.required
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
removeSpecifiedPaths(schemaPaths, '.$*');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
exports.createChart = require('./createChart');
|
|
4
|
+
exports.createDocument = require('./createDocument')
|
|
4
5
|
exports.deleteDocument = require('./deleteDocument');
|
|
5
6
|
exports.exportQueryResults = require('./exportQueryResults');
|
|
6
7
|
exports.getDocument = require('./getDocument');
|
|
@@ -26,7 +26,7 @@ module.exports = ({ db }) => async function updateDocument(params) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const doc = await Model.
|
|
29
|
-
findByIdAndUpdate(_id, update, { sanitizeFilter: true, returnDocument: 'after' });
|
|
29
|
+
findByIdAndUpdate(_id, update, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true });
|
|
30
30
|
|
|
31
31
|
return { doc };
|
|
32
32
|
};
|
package/backend/actions/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const mongoose = require('mongoose');
|
|
4
|
+
|
|
5
|
+
const dashboardSchema = new mongoose.Schema({
|
|
6
|
+
name: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
code: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
module.exports = dashboardSchema;
|
package/backend/index.js
CHANGED
|
@@ -4,9 +4,13 @@ const Actions = require('./actions');
|
|
|
4
4
|
const { applySpec } = require('extrovert');
|
|
5
5
|
const mongoose = require('mongoose');
|
|
6
6
|
|
|
7
|
+
const dashboardSchema = require('./db/dashboardSchema');
|
|
8
|
+
|
|
7
9
|
module.exports = function backend(db) {
|
|
8
10
|
db = db || mongoose.connection;
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
db.model('__Studio_Dashboard', dashboardSchema, '__studio_dashboards');
|
|
13
|
+
|
|
10
14
|
const actions = applySpec(Actions, { db });
|
|
11
15
|
return actions;
|
|
12
16
|
};
|