diff --git a/spec/Schema.spec.js b/spec/Schema.spec.js index d0e5095331..02447080c1 100644 --- a/spec/Schema.spec.js +++ b/spec/Schema.spec.js @@ -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', { diff --git a/src/Schema.js b/src/Schema.js index 3681d04eed..b98519fdfe 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -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'},