mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Fix DS.Model.belongsTo and DS.Model.hasMany args (#25072)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
8c3fdbcf02
commit
16c3ba2628
Vendored
+2
-2
@@ -521,11 +521,11 @@ declare module 'ember-data' {
|
||||
/**
|
||||
* Get the reference for the specified belongsTo relationship.
|
||||
*/
|
||||
belongsTo(name: keyof ModelRegistry): BelongsToReference;
|
||||
belongsTo(name: RelationshipsFor<this>): BelongsToReference;
|
||||
/**
|
||||
* Get the reference for the specified hasMany relationship.
|
||||
*/
|
||||
hasMany(name: keyof ModelRegistry): HasManyReference<any>;
|
||||
hasMany(name: RelationshipsFor<this>): HasManyReference<any>;
|
||||
/**
|
||||
* Given a callback, iterates over each of the relationships in the model,
|
||||
* invoking the callback with the name of each relationship and its relationship
|
||||
|
||||
@@ -16,17 +16,23 @@ class Comment extends DS.Model {
|
||||
author = DS.attr('string');
|
||||
}
|
||||
|
||||
class Series extends DS.Model {
|
||||
title = DS.attr('string');
|
||||
}
|
||||
|
||||
class RelationalPost extends DS.Model {
|
||||
title = DS.attr('string');
|
||||
tag = DS.attr('string');
|
||||
comments = DS.hasMany('comment', { async: true });
|
||||
relatedPosts = DS.hasMany('post');
|
||||
series = DS.belongsTo('series');
|
||||
}
|
||||
|
||||
declare module 'ember-data' {
|
||||
interface ModelRegistry {
|
||||
'relational-post': RelationalPost;
|
||||
comment: Comment;
|
||||
series: Series;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,3 +41,6 @@ blogPost!.get('comments').then((comments) => {
|
||||
// now we can work with the comments
|
||||
let author: string = comments.get('firstObject')!.get('author');
|
||||
});
|
||||
|
||||
blogPost!.hasMany('relatedPosts');
|
||||
blogPost!.belongsTo('series');
|
||||
|
||||
Reference in New Issue
Block a user