We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 53dfca2 commit 0b5cfb2Copy full SHA for 0b5cfb2
schemas.js
@@ -113,18 +113,13 @@ function createSchema(req) {
113
},
114
});
115
}
116
- return req.config.database.collection('_SCHEMA')
117
- .then(coll => Schema.load(coll))
118
- .then(schema => schema.validateClassName(req.body.className))
119
- .catch(error => {
120
- console.log(arguments);
121
- return {response: error};
122
- })
123
- .then(newSchema => {
124
- for (key in newSchema.data) {
125
- }
126
- return {response: {}};
127
- });
+ return req.config.database.loadSchema()
+ .then(schema => schema.addClassIfNotExists(className, req.body.fields))
+ .then(result => ({ response: mongoSchemaToSchemaAPIResponse(result) }))
+ .catch(error => ({
+ status: 400,
+ response: error,
+ }));
128
129
130
router.route('GET', '/schemas', getAllSchemas);
0 commit comments