@mongoosejs/studio 0.0.3 → 0.0.4

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.
@@ -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
- options: Model.schema.paths[path].options
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(sort == null ? { _id: -1 } : 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
- options: Model.schema.paths[path].options
59
+ ref: Model.schema.paths[path].options?.ref
59
60
  };
60
61
  }
61
62
  removeSpecifiedPaths(schemaPaths, '.$*');
@@ -39,7 +39,7 @@
39
39
  <td v-for="schemaPath in schemaPaths">
40
40
  <component
41
41
  :is="getComponentForPath(schemaPath)"
42
- :value="document[schemaPath.path]"
42
+ :value="getValueForPath(document, schemaPath.path)"
43
43
  :allude="getReferenceModel(schemaPath)">
44
44
  </component>
45
45
  </td>
@@ -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
 
@@ -107,7 +108,10 @@ module.exports = app => app.component('models', {
107
108
  return 'list-default';
108
109
  },
109
110
  getReferenceModel(schemaPath) {
110
- return schemaPath.options?.ref;
111
+ return schemaPath.ref;
112
+ },
113
+ getValueForPath(doc, path) {
114
+ return mpath.get(path, doc);
111
115
  },
112
116
  async saveDocEdits() {
113
117
  const res = await api.Model.updateDocument({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",
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
- }
@@ -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
- }