Open SzNagyMisu opened 4 years ago
I have a model like the following one:
class Person extends Model { static entity = 'people' static fields () { return { id: this.attr(), name: this.string(), parentId: this.string(), parent: this.belongsTo(Person, 'parentId') } } }
And I need a getter iterating through the ancestors of one person:
get fullName () { return this.parent ? `${this.name} son of ${this.parent.fullName}` : this.name }
Now, vuex-orm has a method: withAllRecursive, but I have two reasons not to use it for this scenario:
vuex-orm
withAllRecursive
Person
I suggest a new query method withRecursive with the following usage:
withRecursive
Person.query().withRecursive('parent').find(123).fullName
Any thoughts on this?
Sorry for the late response! Yeah this makes sense. Let's mark this as an enhancement issue 👍
I have a model like the following one:
And I need a getter iterating through the ancestors of one person:
Now,
vuex-orm
has a method:withAllRecursive
, but I have two reasons not to use it for this scenario:Person
model has other relations, but I only need this onewithAllRecursive
goes only to a specified depth (defaulting to 3) but I don't know how many ancestors there are for a givenPerson
.I suggest a new query method
withRecursive
with the following usage:Any thoughts on this?