Skip to content

Commit

Permalink
fix: add explicit async and inverse relationship options in test …
Browse files Browse the repository at this point in the history
…app (#285)

* WIP

* Ch

* Update group.ts

* Update post.ts
  • Loading branch information
charlesfries authored Jun 2, 2024
1 parent 7aa56dc commit 4843ca2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion tests/dummy/app/models/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export default class GroupModel extends Model {
@attr('string')
declare public name: string;

@hasMany('user')
@hasMany('user', { async: true, inverse: 'groups' })
declare public members: DS.PromiseManyArray<UserModel>;

@hasMany('post', {
async: true,
inverse: 'group',
isRealtime: true,

filter(reference: Query) {
Expand Down
5 changes: 3 additions & 2 deletions tests/dummy/app/models/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ export default class PostModel extends Model {
@attr('timestamp')
declare public createdOn: TimestampTransform;

@belongsTo('user')
@belongsTo('user', { async: true, inverse: 'posts' })
declare public author: DS.PromiseObject<UserModel>;

@belongsTo('group')
@belongsTo('group', { async: true, inverse: 'posts' })
declare public group: DS.PromiseObject<GroupModel>;

@belongsTo('user', {
async: true,
inverse: null,

buildReference(db: Firestore) {
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export default class UserModel extends Model {
@attr('string')
declare public name: string;

@hasMany('group')
@hasMany('group', { async: true, inverse: 'members' })
declare public groups: DS.PromiseManyArray<GroupModel>;

@hasMany('post')
@hasMany('post', { async: true, inverse: 'author' })
declare public posts: DS.PromiseManyArray<PostModel>;
}

Expand Down

0 comments on commit 4843ca2

Please sign in to comment.