@mongoosejs/studio 0.1.18 → 0.1.20

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.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const Archetype = require('archetype');
4
+ const getRefFromSchemaType = require('../../helpers/getRefFromSchemaType');
4
5
  const removeSpecifiedPaths = require('../../helpers/removeSpecifiedPaths');
5
6
  const authorize = require('../../authorize');
6
7
 
@@ -37,7 +38,7 @@ module.exports = ({ db }) => async function getDocument(params) {
37
38
  schemaPaths[path] = {
38
39
  instance: Model.schema.paths[path].instance,
39
40
  path,
40
- ref: Model.schema.paths[path].options?.ref,
41
+ ref: getRefFromSchemaType(Model.schema.paths[path]),
41
42
  required: Model.schema.paths[path].options?.required,
42
43
  enum: Model.schema.paths[path].options?.enum
43
44
  };
@@ -3,6 +3,7 @@
3
3
  const Archetype = require('archetype');
4
4
  const removeSpecifiedPaths = require('../../helpers/removeSpecifiedPaths');
5
5
  const evaluateFilter = require('../../helpers/evaluateFilter');
6
+ const getRefFromSchemaType = require('../../helpers/getRefFromSchemaType');
6
7
  const authorize = require('../../authorize');
7
8
 
8
9
  const GetDocumentsParams = new Archetype({
@@ -77,7 +78,7 @@ module.exports = ({ db }) => async function getDocuments(params) {
77
78
  schemaPaths[path] = {
78
79
  instance: schemaType.instance,
79
80
  path,
80
- ref: schemaType.options?.ref,
81
+ ref: getRefFromSchemaType(schemaType),
81
82
  required: schemaType.options?.required,
82
83
  enum: schemaType.options?.enum
83
84
  };
@@ -87,7 +88,7 @@ module.exports = ({ db }) => async function getDocuments(params) {
87
88
  schemaPaths[path].schema[subpath] = {
88
89
  instance: schemaType.schema.paths[subpath].instance,
89
90
  path: subpath,
90
- ref: schemaType.schema.paths[subpath].options?.ref,
91
+ ref: getRefFromSchemaType(schemaType.schema.paths[subpath]),
91
92
  required: schemaType.schema.paths[subpath].options?.required,
92
93
  enum: schemaType.schema.paths[subpath].options?.enum
93
94
  };
@@ -3,6 +3,7 @@
3
3
  const Archetype = require('archetype');
4
4
  const removeSpecifiedPaths = require('../../helpers/removeSpecifiedPaths');
5
5
  const evaluateFilter = require('../../helpers/evaluateFilter');
6
+ const getRefFromSchemaType = require('../../helpers/getRefFromSchemaType');
6
7
  const authorize = require('../../authorize');
7
8
 
8
9
  const GetDocumentsParams = new Archetype({
@@ -67,7 +68,7 @@ module.exports = ({ db }) => async function* getDocumentsStream(params) {
67
68
  schemaPaths[path] = {
68
69
  instance: schemaType.instance,
69
70
  path,
70
- ref: schemaType.options?.ref,
71
+ ref: getRefFromSchemaType(schemaType),
71
72
  required: schemaType.options?.required,
72
73
  enum: schemaType.options?.enum
73
74
  };
@@ -77,7 +78,7 @@ module.exports = ({ db }) => async function* getDocumentsStream(params) {
77
78
  schemaPaths[path].schema[subpath] = {
78
79
  instance: schemaType.schema.paths[subpath].instance,
79
80
  path: subpath,
80
- ref: schemaType.schema.paths[subpath].options?.ref,
81
+ ref: getRefFromSchemaType(schemaType.schema.paths[subpath]),
81
82
  required: schemaType.schema.paths[subpath].options?.required,
82
83
  enum: schemaType.schema.paths[subpath].options?.enum
83
84
  };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = function getRefFromSchemaType(schemaType) {
4
+ return schemaType?.options?.ref ?? schemaType?.embeddedSchemaType?.options?.ref ?? schemaType?.caster?.options?.ref;
5
+ };