Model.relatedTypes documentation incorrectly describes classes instead of strings
There is a wrong example in api docs https://api.emberjs.com/ember-data/4.4/classes/Model/properties/relatedTypes?anchor=relatedTypes Doc shows in the example that this method returns the related model classes, while in reality it returns their small-case names. See the correction below.
import Model, { belongsTo, hasMany } from '@ember-data/model';
export default class BlogModel extends Model {
@hasMany('user') users;
@belongsTo('user') owner;
@hasMany('post') posts;
}
import { get } from '@ember/object';
import Blog from 'app/models/blog';
let relatedTypes = Blog.relatedTypes');
//=> [ User, Post ] <-- this line
instead it returns ['user', 'post']
@Elawphant would you be able to send in a doc fix for that? Would love to get that fixed
Give me the link, I would gladly do that.
@Elawphant you bet. Click on https://api.emberjs.com/ember-data/4.4/classes/Model/properties/relatedTypes?anchor=relatedTypes, browse to where it is defined and you should be able to edit the source
It looks like the docs for Model.inverseFor also incorrectly specifies the class as the type on the relationship meta object. Likely this same mistake was made a number of places, probably this was true at one time in the very early days of ember-data.
@runspired I believe so, too. @acorncom github is not letting me do pull request to fix it.
fixed in #8440 (thanks @Shubhi-73). I'll leave this open for Model.inverseFor fix as well.
fixed as part of #9292