Completely migrate SchemasRouter to new MongoCollection API.
This commit is contained in:
@@ -175,7 +175,7 @@ describe('schemas', () => {
|
|||||||
expect(response.statusCode).toEqual(400);
|
expect(response.statusCode).toEqual(400);
|
||||||
expect(body).toEqual({
|
expect(body).toEqual({
|
||||||
code: 103,
|
code: 103,
|
||||||
error: 'class HASALLPOD does not exist',
|
error: 'Class HASALLPOD does not exist.',
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -733,7 +733,7 @@ describe('schemas', () => {
|
|||||||
//Expect _SCHEMA entry to be gone.
|
//Expect _SCHEMA entry to be gone.
|
||||||
expect(response.statusCode).toEqual(400);
|
expect(response.statusCode).toEqual(400);
|
||||||
expect(body.code).toEqual(Parse.Error.INVALID_CLASS_NAME);
|
expect(body.code).toEqual(Parse.Error.INVALID_CLASS_NAME);
|
||||||
expect(body.error).toEqual('class MyOtherClass does not exist');
|
expect(body.error).toEqual('Class MyOtherClass does not exist.');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,16 +45,16 @@ function getAllSchemas(req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getOneSchema(req) {
|
function getOneSchema(req) {
|
||||||
return req.config.database.collection('_SCHEMA')
|
const className = req.params.className;
|
||||||
.then(coll => coll.findOne({'_id': req.params.className}))
|
return req.config.database.adaptiveCollection('_SCHEMA')
|
||||||
.then(schema => ({response: mongoSchemaToSchemaAPIResponse(schema)}))
|
.then(collection => collection.find({ '_id': className }, { limit: 1 }))
|
||||||
.catch(() => ({
|
.then(results => {
|
||||||
status: 400,
|
if (results.length != 1) {
|
||||||
response: {
|
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME, `Class ${className} does not exist.`);
|
||||||
code: 103,
|
|
||||||
error: 'class ' + req.params.className + ' does not exist',
|
|
||||||
}
|
}
|
||||||
}));
|
return results[0];
|
||||||
|
})
|
||||||
|
.then(schema => ({ response: mongoSchemaToSchemaAPIResponse(schema) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSchema(req) {
|
function createSchema(req) {
|
||||||
@@ -70,7 +70,7 @@ function createSchema(req) {
|
|||||||
response: {
|
response: {
|
||||||
code: 135,
|
code: 135,
|
||||||
error: 'POST ' + req.path + ' needs class name',
|
error: 'POST ' + req.path + ' needs class name',
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return req.config.database.loadSchema()
|
return req.config.database.loadSchema()
|
||||||
|
|||||||
Reference in New Issue
Block a user