Skip to content

Commit 0b5cfb2

Browse files
committed
Schemas POST fix tests
1 parent 53dfca2 commit 0b5cfb2

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

schemas.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,13 @@ function createSchema(req) {
113113
},
114114
});
115115
}
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-
});
116+
return req.config.database.loadSchema()
117+
.then(schema => schema.addClassIfNotExists(className, req.body.fields))
118+
.then(result => ({ response: mongoSchemaToSchemaAPIResponse(result) }))
119+
.catch(error => ({
120+
status: 400,
121+
response: error,
122+
}));
128123
}
129124

130125
router.route('GET', '/schemas', getAllSchemas);

0 commit comments

Comments
 (0)