Skip to content

Commit d87579a

Browse files
authored
Ember Data: Fix relationship deprecation warnings (#5578)
see https://rfcs.emberjs.com/id/0739-ember-data-deprecate-non-strict-relationships/
1 parent d393c49 commit d87579a

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

app/models/category.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default class Category extends Model {
1010
@attr subcategories;
1111
@attr parent_categories;
1212

13-
@hasMany('crate', { async: true }) crates;
13+
@hasMany('crate', { async: true, inverse: null }) crates;
1414
}

app/models/crate.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ export default class Crate extends Model {
1717
@attr documentation;
1818
@attr repository;
1919

20-
@hasMany('versions', { async: true }) versions;
21-
22-
@hasMany('teams', { async: true }) owner_team;
23-
@hasMany('users', { async: true }) owner_user;
24-
@hasMany('version-download', { async: true }) version_downloads;
25-
@hasMany('keywords', { async: true }) keywords;
26-
@hasMany('categories', { async: true }) categories;
27-
@hasMany('dependency', { async: true }) reverse_dependencies;
20+
@hasMany('version', { async: true, inverse: 'crate' }) versions;
21+
@hasMany('team', { async: true, inverse: null }) owner_team;
22+
@hasMany('user', { async: true, inverse: null }) owner_user;
23+
@hasMany('version-download', { async: true, inverse: null }) version_downloads;
24+
@hasMany('keyword', { async: true, inverse: null }) keywords;
25+
@hasMany('category', { async: true, inverse: null }) categories;
26+
@hasMany('dependency', { async: true, inverse: null }) reverse_dependencies;
2827

2928
/**
3029
* This is the default version that will be shown when visiting the crate

app/models/dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export default class Dependency extends Model {
1313
@attr kind;
1414
@attr downloads;
1515

16-
@belongsTo('version', { async: false }) version;
16+
@belongsTo('version', { async: false, inverse: 'dependencies' }) version;
1717
}

app/models/keyword.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export default class Keyword extends Model {
55
@attr('date') created_at;
66
@attr crates_cnt;
77

8-
@hasMany('crate', { async: true }) crates;
8+
@hasMany('crate', { async: true, inverse: null }) crates;
99
}

app/models/version-download.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export default class VersionDownload extends Model {
66
/** @type string */
77
@attr date;
88

9-
@belongsTo('version', { async: false }) version;
9+
@belongsTo('version', { async: false, inverse: null }) version;
1010
}

app/models/version.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export default class Version extends Model {
2222
@attr license;
2323
@attr crate_size;
2424

25-
@belongsTo('crate', { async: false }) crate;
25+
@belongsTo('crate', { async: false, inverse: 'versions' }) crate;
2626

27-
@belongsTo('user', { async: false }) published_by;
28-
@hasMany('dependency', { async: true }) dependencies;
29-
@hasMany('version-download', { async: true }) version_downloads;
27+
@belongsTo('user', { async: false, inverse: null }) published_by;
28+
@hasMany('dependency', { async: true, inverse: 'version' }) dependencies;
29+
@hasMany('version-download', { async: true, inverse: null }) version_downloads;
3030

3131
get crateName() {
3232
return this.belongsTo('crate').id();

0 commit comments

Comments
 (0)