Fix create system class with relation/pointer

This commit is contained in:
Marco129
2016-03-03 16:37:30 +08:00
parent c6406b9e1a
commit 90a1e46905
2 changed files with 40 additions and 3 deletions

View File

@@ -422,6 +422,43 @@ describe('Schema', () => {
});
});
it('creates non-custom classes which include relation field', done => {
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('_Role', {}))
.then(mongoObj => {
expect(mongoObj).toEqual({
_id: '_Role',
createdAt: 'string',
updatedAt: 'string',
objectId: 'string',
name: 'string',
users: 'relation<_User>',
roles: 'relation<_Role>',
});
done();
});
});
it('creates non-custom classes which include pointer field', done => {
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('_Session', {}))
.then(mongoObj => {
expect(mongoObj).toEqual({
_id: '_Session',
createdAt: 'string',
updatedAt: 'string',
objectId: 'string',
restricted: 'boolean',
user: '*_User',
installationId: 'string',
sessionToken: 'string',
expiresAt: 'date',
createdWith: 'object'
});
done();
});
});
it('refuses to create two geopoints', done => {
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('NewClass', {

View File

@@ -48,13 +48,13 @@ var defaultColumns = {
// The additional default columns for the _User collection (in addition to DefaultCols)
_Role: {
"name": {type:'String'},
"users": {type:'Relation',className:'_User'},
"roles": {type:'Relation',className:'_Role'}
"users": {type:'Relation', targetClass:'_User'},
"roles": {type:'Relation', targetClass:'_Role'}
},
// The additional default columns for the _User collection (in addition to DefaultCols)
_Session: {
"restricted": {type:'Boolean'},
"user": {type:'Pointer', className:'_User'},
"user": {type:'Pointer', targetClass:'_User'},
"installationId": {type:'String'},
"sessionToken": {type:'String'},
"expiresAt": {type:'Date'},