Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update only one parameter in row #136

Closed
LubomirIgonda1 opened this issue Jul 10, 2017 · 2 comments
Closed

Update only one parameter in row #136

LubomirIgonda1 opened this issue Jul 10, 2017 · 2 comments

Comments

@LubomirIgonda1
Copy link
Contributor

I have issue with update logic

here in this peace of code in your update function

Object.keys(instance.toJSON()).forEach(key => {
  if (typeof data[key] === 'undefined') {
      copy[key] = null;
  } else {
     copy[key] = data[key];
  }
});

This issue occurs when i try to update only a some columns in row.

I have row with 6 columns and I want to update only one specific column in the row. I send id of row, and data only for one column. That one column update correctly but other columns are null because of if statement show above ...

Would it be possible to change this line
copy[key] = null;
for something like this:
copy[key] = "originalValue"

@daffl
Copy link
Member

daffl commented Jul 10, 2017

That's what .update is supposed to do:

update(id, data, params) -> Promise - replaces the resource identified by id with data

What you want to do is what .patch is for:

patch(id, data, params) -> Promise - merges the existing data of the resource identified by id with the new data

@LubomirIgonda1
Copy link
Contributor Author

ok my fault, great and thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants