Comments (9)
+1
from feathers-vuex.
Ah, yes. I haven't handled array responses. Thank you for spotting this. I'll probably be able to fix this over the weekend, unless you have the bandwidth to submit a PR. 🙏
from feathers-vuex.
what should i do to filter that progame catch this error
from feathers-vuex.
Is there any news on this? Based on @tommygarces digging, I've been trying to get it to call addOrUpdateList when the response is an array, but it seems I'm missing something else to make it work as intended.
This is what I tried:
return service.create(data).then(function (item) {
if(item.length){
dispatch('addOrUpdateList', item)
}else{
dispatch('addOrUpdate', item);
}
commit('setCurrent', item);
commit('unsetCreatePending');
return item;
}).catch(function (error) {
commit('setCreateError', error);
commit('unsetCreatePending');
return Promise.reject(error);
});
Everything is added to the db and I get no errors, but already in my backend after create
hook, the PK id
is null
.
from feathers-vuex.
The only Problem I see in this is that 'addOrUpdateList' assumes the provided array is the complete list and will remove all items from the store that are not included in the provided array if autoRemove is turned on.
This is what you expect to happen if you dispatch 'find', but unsuitable if you dispatch an bulk request.
There should maybe be two different actions for bulk requests and find.
You could just dispatch 'addOrUpdate' for each item if the response is an array:
return service.create(data).then(function (item) {
if (Array.isArray(item)) {
item.forEach(function (item) {
dispatch('addOrUpdate', item);
});
} else {
dispatch('addOrUpdate', item);
}
commit('setCurrent', item);
commit('unsetCreatePending');
return item;
}).catch(function (error) {
commit('setCreateError', error);
commit('unsetCreatePending');
return Promise.reject(error);
});
from feathers-vuex.
@Torge thanks for the suggestion, however even when doing it that way, the id = null
for the returned items.
from feathers-vuex.
@bobcat1 sorry i looked at your original issue just now, but it seems like this issue in this thread is dealing with the problem of not handeling the response of bulk 'create' as specified here https://docs.feathersjs.com/api/services#createdata-params
data may also be an array.
Your Problem seems to be, not having an unique single id.
from feathers-vuex.
@Torge This issue is not related to #67.
My use case in relation to this specific issue is:
I'm trying to add an array of items, and then I need to use the IDs returned to add more items, based on the IDs returned from the first array. It's just that all IDs are null
when returned. So my workaround right now is to make a find
call after they have all been added. That way I get all the IDs, and can use them to add the rest of my data.
from feathers-vuex.
This is fixed in the latest pre-release. npm i feathers-vuex@pre
, and it will be included in the next minor version.
from feathers-vuex.
Related Issues (20)
- Any future plans to support Pinia or Vuex 5 stores? HOT 1
- ReplaceItems option doesn't works when patching/updating value with null HOT 2
- Potential Issue with Params.Paginate set to true HOT 1
- FeathersVuexGet component doesn't work with params HOT 1
- add one time sponsor HOT 2
- makeFindMixin uses the same object instance for data HOT 2
- $like operator not working in local getters(using sequelize) HOT 2
- $sort when field data is NULL HOT 4
- Performance issue Find with more than 500 records HOT 18
- Recommended way to use feathers-graph-populate with feathers-vuex auth system
- Auth plugin fails to generate the getters when userService contains a path-like name, e.g 'v1/users'
- [FR] Export BaseModel at the module level
- Keycloak / feathers server and client library HOT 4
- TypeError: Cannot read properties of undefined (reading 'set')
- FeathersVuexPagination does not work with vue 3
- Simple date filter from store not working
- auth user is not updated reactively
- Supporting Vue 2.7 HOT 1
- JWT Malformed error
- Do not clean clone after save inside feathersVuexFormWrapper
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feathers-vuex.