File tree 2 files changed +40
-3
lines changed
2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,43 @@ describe('Schema', () => {
422
422
} ) ;
423
423
} ) ;
424
424
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
+
425
462
it ( 'refuses to create two geopoints' , done => {
426
463
config . database . loadSchema ( )
427
464
. then ( schema => schema . addClassIfNotExists ( 'NewClass' , {
Original file line number Diff line number Diff line change @@ -48,13 +48,13 @@ var defaultColumns = {
48
48
// The additional default columns for the _User collection (in addition to DefaultCols)
49
49
_Role : {
50
50
"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' }
53
53
} ,
54
54
// The additional default columns for the _User collection (in addition to DefaultCols)
55
55
_Session : {
56
56
"restricted" : { type :'Boolean' } ,
57
- "user" : { type :'Pointer' , className :'_User' } ,
57
+ "user" : { type :'Pointer' , targetClass :'_User' } ,
58
58
"installationId" : { type :'String' } ,
59
59
"sessionToken" : { type :'String' } ,
60
60
"expiresAt" : { type :'Date' } ,
You can’t perform that action at this time.
0 commit comments