8

I have multiple models representing user data (profile, settings etc). These at the moment are stored in the models folder like so;

models
  -> user.js
  -> profile.js
  -> settings.js

What I would like to so is have a folder structure like so;

models
  -> user.js
  -> user (folder)
    -> profile.js
    -> settings.js

The user model (user.js) references the profile model (profile.js) like so;

import DS from "ember-data"; 
export default DS.Model.extend({
   NSP: DS.attr('string'),
   Status: DS.attr('string'),
   Profile: DS.belongsTo('profile', {embedded: 'always'})
});

I have tried to replace the DS.belongsTo('profile', {embedded: 'always'}) with the following:

  • DS.belongsTo('user.profile', {embedded: 'always'})
  • DS.belongsTo('user/profile', {embedded: 'always'})
  • DS.belongsTo('user-profile', {embedded: 'always'})

but this does not work.

Am I missing something here?

rog
  • 5,351
  • 5
  • 33
  • 40
JonathanBristow
  • 1,066
  • 2
  • 13
  • 36

1 Answers1

2

Are you sure using "user/profile" doesn't work? I replicated your structure on my system and am getting "user" and "user/profile" models.

Do you have Ember Inspector installed on Firefox or Chrome? You can see the available models easily by going to the "Data" pane:enter image description here

Ruaidhrí Primrose
  • 1,250
  • 1
  • 17
  • 22
  • So when `profile` model is under `user` folder i.e `user/profile`, How do you run createRecord or peekAll ? By this way ~> `this.store.createRecord('user/profile');` `this.store.peekAll('user/profile');` or any other work around ? – rinold simon Jun 24 '18 at 18:19
  • @rinold you'd be best asking that as a new question. I've not used Ember in years so can't give you an answer off the top of my head. – Ruaidhrí Primrose Jun 25 '18 at 08:24