-
-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Environment
No response
Reproduction
Describe the bug
I'm trying out the newly released Axios plugin and am coming across some issues. First of all, thanks so much for making it, as a result I can finally begin to migrate from vuex-orm and it couldn't have come at a better time because I was reaching the limits of what vuex-orm is capable of when I started needing to retrieve and update deep pivot fields.
Anyway, first of all, I found a typo in the setup guide. You refer to createPiniaOrmPluginAxios but it really should be createPiniaOrmAxios
You also write form instead of from.
And you keep referring to useAxiosRepo but without ever mentioning import { useAxiosRepo } from '@pinia-orm/axios';
I know it may be obvious but I also think the setup guide should assume the reader might be completely new to pinia-orm
Anyway on to the real issue.
When I attempt do to this:
await useAxiosRepo(User).api().get('/api/v1/users', {
persistBy: 'insert',
});
I get this error Uncaught (in promise) Error: [Pinia ORM Axios] The axios instance is not registered. Please register the axios instance to the repository.
However, if I add this line above
console.log(`BEFORE: useRepo(User).all().length: ${useRepo(User).all().length}`);
Then I don't get the error. Basically just making a simple call, any call, using useRepo seems to make the error go away.. might be some kind of race condition? Hopefully you can make sense of what the issue is here.
That's it for now.. I will continue my migration and report back my findings.
Unrelated but I was surprised to see that .count() is not a valid method. With vuex-orm I would often get the count like this User.query().count(). This method is very prevalent in Laravel, which I also use extensively. Would be a nice little helper to add I guess. But as you can see above I figured out you can simply chain .length after the .get() too.
Also,
I use
{
persistBy: 'create',
}
and
{
persistBy: 'insertOrUpdate',
}
a lot and was surprised to see those are not valid values with pinia-orm. I couldn't really see where the difference is explained between save and insert in pinia-orm's persistBy configuration.. but maybe I just missed it in the docs.
I guess there isn't an official, or unoffocial migration guide anywhere yet (from vuex-orm) ?
Thanks a lot for making and further developing pinia-orm!!! I look forward to using it now that the Axios plugin is in!
Additional context
No response
Logs
No response