question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating multiple records using service.create(data) with an array yields: no id error

See original GitHub issue

When dispatching create action on a service with an array of multiple objects as data:

var data = [
{name: 'index', permissions: 'guest'},
{name: 'about', permissions: 'guest'},
{name: 'admin', permissions: 'superuser'}
]
store.dispatch('/pages/create', data)

, the following error appears:

Error: No id found for item. Do you need to customize the `idField`?

The data is succesfully added to the database. The problem is when the promise is returned to the action and sent to the addOrUpdate action.

Upon analyzing the create action in src/service-module/actions.js, it seems that the error is produced by treating the response of the service.create(data) as a single object and passing that to addOrUpdate instead of addOrUpdateList:

create ({ commit, dispatch }, data) {
      commit('setCreatePending')

      return service.create(data)
        .then(item => {
          dispatch('addOrUpdate', item)
          commit('setCurrent', item)
          commit('unsetCreatePending')
          return item
        })
        .catch(error => {
          commit('setCreateError', error)
          commit('unsetCreatePending')
          return Promise.reject(error)
        })
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fionagithubcommented, Nov 17, 2017

+1

0reactions
marshallswaincommented, Mar 30, 2018

This is fixed in the latest pre-release. npm i feathers-vuex@pre, and it will be included in the next minor version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating multiple records using service.create(data) with an ...
When dispatching create action on a service with an array of multiple ... using service.create(data) with an array yields: no id error #61....
Read more >
Order of returned Ids when creating multiple records with the ...
When I create records using the SOAP API, the Id of the created records are returned, and if multiple records are created in...
Read more >
Not able to delete multiple records from database having array ...
I have a service.ts file that calls HTTP Client method to delete multiple records from db. But when I'm passing multiple Id's in...
Read more >
Create Multiple Records with Fewer Round-Trips
You can't create records for multiple object types in one call when one of the types is related to a feature in the...
Read more >
5. Working with Arrays and Loops - JavaScript Cookbook [Book]
Not all array elements have to be defined when created. For instance, if you create an array literal, you can use commas to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found