data icon indicating copy to clipboard operation
data copied to clipboard

Model.relatedTypes documentation incorrectly describes classes instead of strings

Open Elawphant opened this issue 3 years ago • 6 comments

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 avatar Jul 06 '22 19:07 Elawphant

@Elawphant would you be able to send in a doc fix for that? Would love to get that fixed

acorncom avatar Jul 14 '22 07:07 acorncom

Give me the link, I would gladly do that.

Elawphant avatar Jul 14 '22 07:07 Elawphant

@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

acorncom avatar Jul 14 '22 09:07 acorncom

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 avatar Jul 15 '22 21:07 runspired

@runspired I believe so, too. @acorncom github is not letting me do pull request to fix it.

Elawphant avatar Jul 16 '22 12:07 Elawphant

fixed in #8440 (thanks @Shubhi-73). I'll leave this open for Model.inverseFor fix as well.

runspired avatar Feb 27 '23 23:02 runspired

fixed as part of #9292

runspired avatar Apr 14 '24 02:04 runspired