ember-parse-adapter icon indicating copy to clipboard operation
ember-parse-adapter copied to clipboard

additional user attributes

Open CrokinoleMaster opened this issue 10 years ago • 4 comments

I'm having fun trying your adapter but I was wondering if it's possible to add more attributes to User Model.

App.User = DS.ParseUserModel.extend({
    posts: DS.hasMany('post')
});

Something like this doesn't work. Is there another way to do it?

Also is there a way to access the model through store?

var user = this.store.find('user');
user.get('username')  

returns undefined even though username is in DS.ParseUserModel.

I'm still a student so I'm not sure if these are dumb questions but if you could help me with them that would be great! thanks

CrokinoleMaster avatar Mar 14 '14 22:03 CrokinoleMaster

Sorry turns out they were stupid questions because I got it working!

CrokinoleMaster avatar Mar 15 '14 03:03 CrokinoleMaster

I am however having an issue with associations on a user object after logging that user in. Assume this:

App.User = DS.ParseUserModel.extend({
    posts: DS.hasMany("post")
});
App.User.login(@get("email"), @get("password"))

then if I try to access the "posts" property I get this error:

Error: Assertion Failed: You looked up the 'posts' relationship on '<(subclass of DS.ParseUserModel):ember643:qMpHlel4II>' but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (`DS.hasMany({ async: true })`)

However, this error can be avoided if the user is loaded first:

this.get("store").find("user", userId)

Can anyone confirm?

conrad-vanl avatar May 16 '14 14:05 conrad-vanl

@conrad-vanl do you still get the bad behavior? What if you make the relationship {async: true}?

mixonic avatar Jun 24 '14 19:06 mixonic

regarding adding additional attributes, related to #50

musnit avatar Dec 02 '14 14:12 musnit