Skip to content

Commit 90a1e46

Browse files
committed
Fix create system class with relation/pointer
1 parent c6406b9 commit 90a1e46

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

spec/Schema.spec.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,43 @@ describe('Schema', () => {
422422
});
423423
});
424424

425+
it('creates non-custom classes which include relation field', done => {
426+
config.database.loadSchema()
427+
.then(schema => schema.addClassIfNotExists('_Role', {}))
428+
.then(mongoObj => {
429+
expect(mongoObj).toEqual({
430+
_id: '_Role',
431+
createdAt: 'string',
432+
updatedAt: 'string',
433+
objectId: 'string',
434+
name: 'string',
435+
users: 'relation<_User>',
436+
roles: 'relation<_Role>',
437+
});
438+
done();
439+
});
440+
});
441+
442+
it('creates non-custom classes which include pointer field', done => {
443+
config.database.loadSchema()
444+
.then(schema => schema.addClassIfNotExists('_Session', {}))
445+
.then(mongoObj => {
446+
expect(mongoObj).toEqual({
447+
_id: '_Session',
448+
createdAt: 'string',
449+
updatedAt: 'string',
450+
objectId: 'string',
451+
restricted: 'boolean',
452+
user: '*_User',
453+
installationId: 'string',
454+
sessionToken: 'string',
455+
expiresAt: 'date',
456+
createdWith: 'object'
457+
});
458+
done();
459+
});
460+
});
461+
425462
it('refuses to create two geopoints', done => {
426463
config.database.loadSchema()
427464
.then(schema => schema.addClassIfNotExists('NewClass', {

src/Schema.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ var defaultColumns = {
4848
// The additional default columns for the _User collection (in addition to DefaultCols)
4949
_Role: {
5050
"name": {type:'String'},
51-
"users": {type:'Relation',className:'_User'},
52-
"roles": {type:'Relation',className:'_Role'}
51+
"users": {type:'Relation', targetClass:'_User'},
52+
"roles": {type:'Relation', targetClass:'_Role'}
5353
},
5454
// The additional default columns for the _User collection (in addition to DefaultCols)
5555
_Session: {
5656
"restricted": {type:'Boolean'},
57-
"user": {type:'Pointer', className:'_User'},
57+
"user": {type:'Pointer', targetClass:'_User'},
5858
"installationId": {type:'String'},
5959
"sessionToken": {type:'String'},
6060
"expiresAt": {type:'Date'},

0 commit comments

Comments
 (0)