@@ -11,8 +11,8 @@ export class User extends ORMModel {
1111 id : this . increment ( 0 ) ,
1212 name : this . string ( '' ) ,
1313 profileId : this . number ( 0 ) ,
14- posts : this . hasMany ( Post , 'userId ' ) ,
15- comments : this . hasMany ( Comment , 'userId ' ) ,
14+ posts : this . hasMany ( Post , 'authorId ' ) ,
15+ comments : this . hasMany ( Comment , 'authorId ' ) ,
1616 profile : this . belongsTo ( Profile , 'profileId' )
1717 } ;
1818 }
@@ -41,10 +41,10 @@ export class Video extends ORMModel {
4141 id : this . increment ( null ) ,
4242 content : this . string ( '' ) ,
4343 title : this . string ( '' ) ,
44- userId : this . number ( 0 ) ,
44+ authorId : this . number ( 0 ) ,
4545 otherId : this . number ( 0 ) , // This is a field which ends with `Id` but doesn't belong to any relation
4646 ignoreMe : this . string ( '' ) ,
47- user : this . belongsTo ( User , 'userId ' ) ,
47+ author : this . belongsTo ( User , 'authorId ' ) ,
4848 comments : this . morphMany ( Comment , 'subjectId' , 'subjectType' )
4949 } ;
5050 }
@@ -59,10 +59,10 @@ export class Post extends ORMModel {
5959 id : this . increment ( null ) ,
6060 content : this . string ( '' ) ,
6161 title : this . string ( '' ) ,
62- userId : this . number ( 0 ) ,
62+ authorId : this . number ( 0 ) ,
6363 otherId : this . number ( 0 ) , // This is a field which ends with `Id` but doesn't belong to any relation
6464 published : this . boolean ( true ) ,
65- user : this . belongsTo ( User , 'userId ' ) ,
65+ author : this . belongsTo ( User , 'authorId ' ) ,
6666 comments : this . morphMany ( Comment , 'subjectId' , 'subjectType' )
6767 } ;
6868 }
@@ -76,8 +76,8 @@ export class Comment extends ORMModel {
7676 return {
7777 id : this . increment ( 0 ) ,
7878 content : this . string ( '' ) ,
79- userId : this . number ( 0 ) ,
80- user : this . belongsTo ( User , 'userId ' ) ,
79+ authorId : this . number ( 0 ) ,
80+ author : this . belongsTo ( User , 'authorId ' ) ,
8181
8282 subjectId : this . number ( 0 ) ,
8383 subjectType : this . string ( '' )
@@ -147,18 +147,5 @@ export async function setupMockData() {
147147 { model : TariffTariffOption }
148148 ] ) ;
149149
150- /*await Profile.insert({ data: { id: 1, age: 8, sex: true, email: 'charly@peanuts .com' }});
151- await Profile.insert({ data: { id: 2, age: 9, sex: false, email: 'pepper@peanuts .com' }});
152-
153- await User.insert({ data: { id: 1, name: 'Charlie Brown', profileId: 1 }});
154- await User.insert({ data: { id: 2, name: 'Peppermint Patty', profileId: 2 }});
155-
156- await Post.insert({ data: { id: 1, otherId: 9, userId: 1, title: 'Example post 1', content: 'Foo' }});
157- await Post.insert({ data: { id: 2, otherId: 10, userId: 1, title: 'Example post 2', content: 'Bar' }});
158- await Video.insert({ data: { id: 1, otherId: 11, userId: 1, title: 'Example video', content: 'Video' }});
159- await Comment.insert({ data: { id: 1, userId: 1, subjectId: 1, subjectType: 'videos', content: 'Example comment 1' }});
160- await Comment.insert({ data: { id: 2, userId: 2, subjectId: 1, subjectType: 'posts', content: 'Example comment 2' }});
161- await Comment.insert({ data: { id: 3, userId: 2, subjectId: 2, subjectType: 'posts', content: 'Example comment 3' }});*/
162-
163150 return [ store , vuexOrmGraphQL ] ;
164151}
0 commit comments