@mongoosejs/studio 0.0.3 → 0.0.5
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/getDocument.js +1 -1
- package/backend/actions/Model/getDocuments.js +3 -2
- package/frontend/src/models/models.html +1 -1
- package/frontend/src/models/models.js +22 -4
- package/package.json +1 -1
- package/mongoose.js +0 -20
- package/scripts/stratos.js +0 -22
- package/stargate.js +0 -26
- package/stratos.js +0 -20
- package/tv.js +0 -20
- package/zevo.js +0 -20
|
@@ -31,7 +31,7 @@ module.exports = ({ db }) => async function getDocument(params) {
|
|
|
31
31
|
schemaPaths[path] = {
|
|
32
32
|
instance: Model.schema.paths[path].instance,
|
|
33
33
|
path,
|
|
34
|
-
|
|
34
|
+
ref: Model.schema.paths[path].options?.ref
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
removeSpecifiedPaths(schemaPaths, '.$*');
|
|
@@ -44,18 +44,19 @@ module.exports = ({ db }) => async function getDocuments(params) {
|
|
|
44
44
|
filter = { '$**': filter };
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const hasSort = typeof sort === 'object' && sort != null && Object.keys(sort).length > 0;
|
|
47
48
|
const docs = await Model.
|
|
48
49
|
find(filter == null ? {} : filter).
|
|
49
50
|
limit(limit).
|
|
50
51
|
skip(skip).
|
|
51
|
-
sort(
|
|
52
|
+
sort(hasSort ? sort : { _id: -1 });
|
|
52
53
|
|
|
53
54
|
let schemaPaths = {};
|
|
54
55
|
for (const path of Object.keys(Model.schema.paths)) {
|
|
55
56
|
schemaPaths[path] = {
|
|
56
57
|
instance: Model.schema.paths[path].instance,
|
|
57
58
|
path,
|
|
58
|
-
|
|
59
|
+
ref: Model.schema.paths[path].options?.ref
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
removeSpecifiedPaths(schemaPaths, '.$*');
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const api = require('../api');
|
|
4
4
|
const template = require('./models.html');
|
|
5
5
|
const EJSON = require('ejson');
|
|
6
|
+
const mpath = require('mpath');
|
|
6
7
|
|
|
7
8
|
const appendCSS = require('../appendCSS');
|
|
8
9
|
|
|
@@ -24,7 +25,8 @@ module.exports = app => app.component('models', {
|
|
|
24
25
|
searchText: '',
|
|
25
26
|
shouldShowExportModal: false,
|
|
26
27
|
shouldExport: {},
|
|
27
|
-
sortBy: {}
|
|
28
|
+
sortBy: {},
|
|
29
|
+
query: {}
|
|
28
30
|
}),
|
|
29
31
|
created() {
|
|
30
32
|
this.currentModel = this.model;
|
|
@@ -34,11 +36,18 @@ module.exports = app => app.component('models', {
|
|
|
34
36
|
if (this.currentModel == null && this.models.length > 0) {
|
|
35
37
|
this.currentModel = this.models[0];
|
|
36
38
|
}
|
|
39
|
+
this.query = Object.assign({}, this.$route.query); // important that this is here before the if statements
|
|
37
40
|
if (this.$route.query?.search) {
|
|
38
41
|
this.searchText = this.$route.query.search;
|
|
39
42
|
this.filter = eval(`(${this.$route.query.search})`);
|
|
40
43
|
this.filter = EJSON.stringify(this.filter);
|
|
41
44
|
}
|
|
45
|
+
if (this.$route.query?.sort) {
|
|
46
|
+
const sort = eval(`(${this.$route.query.sort})`);
|
|
47
|
+
const path = Object.keys(sort)[0];
|
|
48
|
+
const num = Object.values(sort)[0];
|
|
49
|
+
this.sortDocs(num, path);
|
|
50
|
+
}
|
|
42
51
|
|
|
43
52
|
if (this.currentModel != null) {
|
|
44
53
|
await this.getDocuments();
|
|
@@ -51,12 +60,16 @@ module.exports = app => app.component('models', {
|
|
|
51
60
|
let sorted = false;
|
|
52
61
|
if (this.sortBy[path] == num) {
|
|
53
62
|
sorted = true;
|
|
63
|
+
delete this.query.sort;
|
|
64
|
+
this.$router.push({ query: this.query });
|
|
54
65
|
}
|
|
55
66
|
for (const key in this.sortBy) {
|
|
56
67
|
delete this.sortBy[key];
|
|
57
68
|
}
|
|
58
69
|
if (!sorted) {
|
|
59
70
|
this.sortBy[path] = num;
|
|
71
|
+
this.query.sort = `{${path}:${num}}`
|
|
72
|
+
this.$router.push({ query: this.query });
|
|
60
73
|
}
|
|
61
74
|
await this.getDocuments();
|
|
62
75
|
},
|
|
@@ -64,10 +77,12 @@ module.exports = app => app.component('models', {
|
|
|
64
77
|
if (this.searchText && Object.keys(this.searchText).length) {
|
|
65
78
|
this.filter = eval(`(${this.searchText})`);
|
|
66
79
|
this.filter = EJSON.stringify(this.filter);
|
|
67
|
-
this
|
|
80
|
+
this.query.search = this.searchText;
|
|
81
|
+
this.$router.push({ path: this.$route.path, query: this.query })
|
|
68
82
|
} else {
|
|
69
83
|
this.filter = {};
|
|
70
|
-
|
|
84
|
+
delete this.query.search;
|
|
85
|
+
this.$router.push({ path: this.$route.path, query: this.query });
|
|
71
86
|
}
|
|
72
87
|
await this.getDocuments();
|
|
73
88
|
},
|
|
@@ -107,7 +122,10 @@ module.exports = app => app.component('models', {
|
|
|
107
122
|
return 'list-default';
|
|
108
123
|
},
|
|
109
124
|
getReferenceModel(schemaPath) {
|
|
110
|
-
return schemaPath.
|
|
125
|
+
return schemaPath.ref;
|
|
126
|
+
},
|
|
127
|
+
getValueForPath(doc, path) {
|
|
128
|
+
return mpath.get(path, doc);
|
|
111
129
|
},
|
|
112
130
|
async saveDocEdits() {
|
|
113
131
|
const res = await api.Model.updateDocument({
|
package/package.json
CHANGED
package/mongoose.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const db = require('../backend/src/db');
|
|
4
|
-
const express = require('express');
|
|
5
|
-
const studio = require('./express');
|
|
6
|
-
|
|
7
|
-
run().catch(err => {
|
|
8
|
-
console.error(err);
|
|
9
|
-
process.exit(-1);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
async function run() {
|
|
13
|
-
const app = express();
|
|
14
|
-
const conn = await db();
|
|
15
|
-
|
|
16
|
-
app.use('/studio', studio('/studio/api', conn));
|
|
17
|
-
|
|
18
|
-
await app.listen(3002);
|
|
19
|
-
console.log('Listening on port 3002');
|
|
20
|
-
}
|
package/scripts/stratos.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// env MONGODB\_CONNECTION\_STRING="mongodb://localhost:27017/stratos_local" node ./stratos.js
|
|
4
|
-
|
|
5
|
-
const db = require('../../BirbAI/backend/db'); // user dependent
|
|
6
|
-
const express = require('express');
|
|
7
|
-
const studio = require('../express');
|
|
8
|
-
|
|
9
|
-
run().catch(err => {
|
|
10
|
-
console.error(err);
|
|
11
|
-
process.exit(-1);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
async function run() {
|
|
15
|
-
const app = express();
|
|
16
|
-
const conn = await db();
|
|
17
|
-
|
|
18
|
-
app.use('/studio', studio('/studio/api', conn));
|
|
19
|
-
|
|
20
|
-
await app.listen(3002);
|
|
21
|
-
console.log('Listening on port 3002');
|
|
22
|
-
}
|
package/stargate.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const express = require('express');
|
|
4
|
-
const studio = require('./express');
|
|
5
|
-
|
|
6
|
-
const mongoose = require('../stargate-mongoose-sample-apps/netlify-functions-ecommerce/node_modules/mongoose');
|
|
7
|
-
const { driver } =require('../stargate-mongoose-sample-apps/netlify-functions-ecommerce/node_modules/stargate-mongoose');
|
|
8
|
-
mongoose.setDriver(driver);
|
|
9
|
-
|
|
10
|
-
require('../stargate-mongoose-sample-apps/netlify-functions-ecommerce/models');
|
|
11
|
-
const connect = require('../stargate-mongoose-sample-apps/netlify-functions-ecommerce/connect');
|
|
12
|
-
|
|
13
|
-
run().catch(err => {
|
|
14
|
-
console.error(err);
|
|
15
|
-
process.exit(-1);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
async function run() {
|
|
19
|
-
await connect();
|
|
20
|
-
const app = express();
|
|
21
|
-
|
|
22
|
-
app.use('/studio', studio('/studio/api', mongoose.connection));
|
|
23
|
-
|
|
24
|
-
await app.listen(3002);
|
|
25
|
-
console.log('Listening on port 3002');
|
|
26
|
-
}
|
package/stratos.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const db = require('../stratos-ai/backend/db');
|
|
4
|
-
const express = require('express');
|
|
5
|
-
const studio = require('./express');
|
|
6
|
-
|
|
7
|
-
run().catch(err => {
|
|
8
|
-
console.error(err);
|
|
9
|
-
process.exit(-1);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
async function run() {
|
|
13
|
-
const app = express();
|
|
14
|
-
const conn = await db();
|
|
15
|
-
|
|
16
|
-
app.use('/studio', studio('/studio/api', conn));
|
|
17
|
-
|
|
18
|
-
await app.listen(3002);
|
|
19
|
-
console.log('Listening on port 3002');
|
|
20
|
-
}
|
package/tv.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const db = require('../terravera.com/backend/connect');
|
|
4
|
-
const express = require('express');
|
|
5
|
-
const studio = require('./express');
|
|
6
|
-
|
|
7
|
-
run().catch(err => {
|
|
8
|
-
console.error(err);
|
|
9
|
-
process.exit(-1);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
async function run() {
|
|
13
|
-
const app = express();
|
|
14
|
-
const conn = await db();
|
|
15
|
-
|
|
16
|
-
app.use('/studio', studio('/studio/api', conn));
|
|
17
|
-
|
|
18
|
-
await app.listen(3002);
|
|
19
|
-
console.log('Listening on port 3002');
|
|
20
|
-
}
|
package/zevo.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const db = require('../../voltmobile/core-api/backend/db');
|
|
4
|
-
const express = require('express');
|
|
5
|
-
const studio = require('./express');
|
|
6
|
-
|
|
7
|
-
run().catch(err => {
|
|
8
|
-
console.error(err);
|
|
9
|
-
process.exit(-1);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
async function run() {
|
|
13
|
-
const app = express();
|
|
14
|
-
const conn = await db();
|
|
15
|
-
|
|
16
|
-
app.use('/studio', studio('/studio/api', conn));
|
|
17
|
-
|
|
18
|
-
await app.listen(3002);
|
|
19
|
-
console.log('Listening on port 3002');
|
|
20
|
-
}
|