diff --git a/app/models/category.js b/app/models/category.js index 0cb10c1ce4d..1c1342d717d 100644 --- a/app/models/category.js +++ b/app/models/category.js @@ -10,5 +10,5 @@ export default class Category extends Model { @attr subcategories; @attr parent_categories; - @hasMany('crate', { async: true }) crates; + @hasMany('crate', { async: true, inverse: null }) crates; } diff --git a/app/models/crate.js b/app/models/crate.js index d4cd2e315ab..d4edc7c42e0 100644 --- a/app/models/crate.js +++ b/app/models/crate.js @@ -17,14 +17,13 @@ export default class Crate extends Model { @attr documentation; @attr repository; - @hasMany('versions', { async: true }) versions; - - @hasMany('teams', { async: true }) owner_team; - @hasMany('users', { async: true }) owner_user; - @hasMany('version-download', { async: true }) version_downloads; - @hasMany('keywords', { async: true }) keywords; - @hasMany('categories', { async: true }) categories; - @hasMany('dependency', { async: true }) reverse_dependencies; + @hasMany('version', { async: true, inverse: 'crate' }) versions; + @hasMany('team', { async: true, inverse: null }) owner_team; + @hasMany('user', { async: true, inverse: null }) owner_user; + @hasMany('version-download', { async: true, inverse: null }) version_downloads; + @hasMany('keyword', { async: true, inverse: null }) keywords; + @hasMany('category', { async: true, inverse: null }) categories; + @hasMany('dependency', { async: true, inverse: null }) reverse_dependencies; /** * This is the default version that will be shown when visiting the crate diff --git a/app/models/dependency.js b/app/models/dependency.js index 972b4ca6038..2428fe5eb71 100644 --- a/app/models/dependency.js +++ b/app/models/dependency.js @@ -13,5 +13,5 @@ export default class Dependency extends Model { @attr kind; @attr downloads; - @belongsTo('version', { async: false }) version; + @belongsTo('version', { async: false, inverse: 'dependencies' }) version; } diff --git a/app/models/keyword.js b/app/models/keyword.js index 3217de29e44..214437a050b 100644 --- a/app/models/keyword.js +++ b/app/models/keyword.js @@ -5,5 +5,5 @@ export default class Keyword extends Model { @attr('date') created_at; @attr crates_cnt; - @hasMany('crate', { async: true }) crates; + @hasMany('crate', { async: true, inverse: null }) crates; } diff --git a/app/models/version-download.js b/app/models/version-download.js index b562d36b32b..3e91243c0b1 100644 --- a/app/models/version-download.js +++ b/app/models/version-download.js @@ -6,5 +6,5 @@ export default class VersionDownload extends Model { /** @type string */ @attr date; - @belongsTo('version', { async: false }) version; + @belongsTo('version', { async: false, inverse: null }) version; } diff --git a/app/models/version.js b/app/models/version.js index b80b4bc0a86..81f4e423023 100644 --- a/app/models/version.js +++ b/app/models/version.js @@ -22,11 +22,11 @@ export default class Version extends Model { @attr license; @attr crate_size; - @belongsTo('crate', { async: false }) crate; + @belongsTo('crate', { async: false, inverse: 'versions' }) crate; - @belongsTo('user', { async: false }) published_by; - @hasMany('dependency', { async: true }) dependencies; - @hasMany('version-download', { async: true }) version_downloads; + @belongsTo('user', { async: false, inverse: null }) published_by; + @hasMany('dependency', { async: true, inverse: 'version' }) dependencies; + @hasMany('version-download', { async: true, inverse: null }) version_downloads; get crateName() { return this.belongsTo('crate').id();