Open phortx opened 5 years ago
regarding pagination you can maybe get around this by simply setting a model with an attribute which identifies it as a Paginator Model.
Then simply ORM create instead of ORM insert.
So you could do BlogPostPaginator.fetch()
this was a relatively easy solution for me and allowed me to maintain state of pagination of each model.
Regarding eager loading I found that there were a lot of problems automatically loading certain relations especially if certain relations are expensive by default.
Laravel's Eloquent ORM is really quite nice.
post->with(['comments.likes','comments.images'])->fetch()
We should be able to temporarily set eager relations using a with method - this would really be handy.
Pivoting is also very important and quite lacking.
I am solving some of these issues, I'll let u know if i come to any findings with my work.
A few other things.
can be quite a problem when it's not separated out I feel. or maybe allow you to specify the input names for the above 2 crud operations.
Thank you very much for your input @tonipepperoni ! :)
Regarding eager loading I found that there were a lot of problems automatically loading certain relations especially if certain relations are expensive by default.
Good point, maybe we should add a skipEagerLoading
or something to make sure that stuff that is normally eagerly loaded (hasOne, belongsTo) are not loaded automatically. For expensive records this would help I think.
Laravel's Eloquent ORM is really quite nice. post->with(['comments.likes','comments.images'])->fetch() We should be able to temporarily set eager relations using a with method - this would really be handy.
a with
(and without
) option was one of the early ideas. We should revive this: #104
Pivoting is also very important and quite lacking.
What's the issue here? I mean what do you actually need, what doesn't work?
should have a flag which simply does vuex orm .create() instead of a .insert() (would solve pagination)
Using create()
instead of insert()
can cause issues. I currently don't remember what kind of issues, but I think it has something to do with IDs. I will investigate on this: #105
should change schema so inputs are named more specifically e.g.: CreatePostInput UpdatePostInput
You can do this via adapters.
Maybe the ideal option is in your is to have a connection setting which eagerloads such relations by default.
This issue with create and insert is probably because create only makes 1 vuex orm record, which is good for pagination, auth-user etc (singletons). but bad for multiple records.
I think having two separate actions is appropriate and worked well for me.
I like the philosophy of hiding such complexity from the user. .fetch()
should just work and one should not think about which kind of operation on the store is used.
I will check this when I have some time :) Thanks for your help.
for pivots -> refers to store models where the primary key is a combination of 2 foreign keys (usually)
@phortx maybe if you want it to be really simple then you could have a flag in the vuex-orm model itself like createOnly = true;
but I think the problem is that in certain cases you would want it to create and other times you'd want it to insert.
Subscriptions are not on the list so I guess they won't make it into 1.0.0? I can't find any infos regarding PRs related to subscriptions either?