Fix create system class with relation/pointer
This commit is contained in:
@@ -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 => {
|
it('refuses to create two geopoints', done => {
|
||||||
config.database.loadSchema()
|
config.database.loadSchema()
|
||||||
.then(schema => schema.addClassIfNotExists('NewClass', {
|
.then(schema => schema.addClassIfNotExists('NewClass', {
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ var defaultColumns = {
|
|||||||
// The additional default columns for the _User collection (in addition to DefaultCols)
|
// The additional default columns for the _User collection (in addition to DefaultCols)
|
||||||
_Role: {
|
_Role: {
|
||||||
"name": {type:'String'},
|
"name": {type:'String'},
|
||||||
"users": {type:'Relation',className:'_User'},
|
"users": {type:'Relation', targetClass:'_User'},
|
||||||
"roles": {type:'Relation',className:'_Role'}
|
"roles": {type:'Relation', targetClass:'_Role'}
|
||||||
},
|
},
|
||||||
// The additional default columns for the _User collection (in addition to DefaultCols)
|
// The additional default columns for the _User collection (in addition to DefaultCols)
|
||||||
_Session: {
|
_Session: {
|
||||||
"restricted": {type:'Boolean'},
|
"restricted": {type:'Boolean'},
|
||||||
"user": {type:'Pointer', className:'_User'},
|
"user": {type:'Pointer', targetClass:'_User'},
|
||||||
"installationId": {type:'String'},
|
"installationId": {type:'String'},
|
||||||
"sessionToken": {type:'String'},
|
"sessionToken": {type:'String'},
|
||||||
"expiresAt": {type:'Date'},
|
"expiresAt": {type:'Date'},
|
||||||
|
|||||||
Reference in New Issue
Block a user