Using a Computed Properties to simplify relation #1279
Unanswered
rodolphonetto
asked this question in
Help
Replies: 3 comments 7 replies
-
I didn't understand what you're trying to do. Which version are you using? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Hmm, I don't think there's something like that, but you can merge two objects together const newObject = {
...objectOne,
...objectTwo // careful, if keys collide with object one, then it will overwrite those
} Or use Object.assign() |
Beta Was this translation helpful? Give feedback.
1 reply
-
I think there could be a workaround. @hasOne(()=>Details,{serializedAs: null))
public details: HasOne<typeof Details>
@computed()
public get title(){
if(this.details){
return this.details.title
}return null Note, the serializeAs: null makes sure that details field is not returned with the selected_answer model |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I've a relation where in the father I've the id and the child (details) I've the title. They are related using a hasOne, so I need to put a .with('details') to see the title, but I don't want to enter the details.title to get the title, there is a way to set a computed propertie in the model where it send the title directly?
Beta Was this translation helpful? Give feedback.
All reactions