@mongoosejs/studio 0.1.5 → 0.1.7

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.
@@ -73,13 +73,26 @@ module.exports = ({ db }) => async function getDocuments(params) {
73
73
 
74
74
  const schemaPaths = {};
75
75
  for (const path of Object.keys(Model.schema.paths)) {
76
+ const schemaType = Model.schema.paths[path];
76
77
  schemaPaths[path] = {
77
- instance: Model.schema.paths[path].instance,
78
+ instance: schemaType.instance,
78
79
  path,
79
- ref: Model.schema.paths[path].options?.ref,
80
- required: Model.schema.paths[path].options?.required,
81
- enum: Model.schema.paths[path].options?.enum
80
+ ref: schemaType.options?.ref,
81
+ required: schemaType.options?.required,
82
+ enum: schemaType.options?.enum
82
83
  };
84
+ if (schemaType.schema) {
85
+ schemaPaths[path].schema = {};
86
+ for (const subpath of Object.keys(schemaType.schema.paths)) {
87
+ schemaPaths[path].schema[subpath] = {
88
+ instance: schemaType.schema.paths[subpath].instance,
89
+ path: subpath,
90
+ ref: schemaType.schema.paths[subpath].options?.ref,
91
+ required: schemaType.schema.paths[subpath].options?.required,
92
+ enum: schemaType.schema.paths[subpath].options?.enum
93
+ };
94
+ }
95
+ }
83
96
  }
84
97
  removeSpecifiedPaths(schemaPaths, '.$*');
85
98
 
@@ -63,13 +63,26 @@ module.exports = ({ db }) => async function* getDocumentsStream(params) {
63
63
 
64
64
  const schemaPaths = {};
65
65
  for (const path of Object.keys(Model.schema.paths)) {
66
+ const schemaType = Model.schema.paths[path];
66
67
  schemaPaths[path] = {
67
- instance: Model.schema.paths[path].instance,
68
+ instance: schemaType.instance,
68
69
  path,
69
- ref: Model.schema.paths[path].options?.ref,
70
- required: Model.schema.paths[path].options?.required,
71
- enum: Model.schema.paths[path].options?.enum
70
+ ref: schemaType.options?.ref,
71
+ required: schemaType.options?.required,
72
+ enum: schemaType.options?.enum
72
73
  };
74
+ if (schemaType.schema) {
75
+ schemaPaths[path].schema = {};
76
+ for (const subpath of Object.keys(schemaType.schema.paths)) {
77
+ schemaPaths[path].schema[subpath] = {
78
+ instance: schemaType.schema.paths[subpath].instance,
79
+ path: subpath,
80
+ ref: schemaType.schema.paths[subpath].options?.ref,
81
+ required: schemaType.schema.paths[subpath].options?.required,
82
+ enum: schemaType.schema.paths[subpath].options?.enum
83
+ };
84
+ }
85
+ }
73
86
  }
74
87
  removeSpecifiedPaths(schemaPaths, '.$*');
75
88