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

DS#commit #243

Closed
jmdobry opened this issue Oct 22, 2015 · 4 comments
Closed

DS#commit #243

jmdobry opened this issue Oct 22, 2015 · 4 comments
Assignees

Comments

@jmdobry
Copy link
Member

jmdobry commented Oct 22, 2015

Initial implementation:

commit (resourceName, id) {
  let {_this, definition, _resourceName, _id} = check.call(this, 'commit', resourceName, id)
  let resource = _this.store[_resourceName]
  let item = _this.store[_resourceName].index[_id]
  if (item) {
    resource.previousAttributes[_id] = DSUtils.copy(item, null, null, null, definition.relationFields)
  }

  if (resource.changeHistories[_id].length) {
    DSUtils.forEach(resource.changeHistories[_id], function (changeRecord) {
      DSUtils.remove(resource.changeHistory, changeRecord)
    })
    resource.changeHistories[_id].splice(0, resource.changeHistories[_id].length)
  }
  return item
}
@jmdobry jmdobry self-assigned this Oct 22, 2015
jmdobry added a commit that referenced this issue Oct 22, 2015
@robertdp
Copy link

I think the intention behind this is to provide an alternative to inject() and its all-or-nothing approach to change histories.

@internalfx wants a way to clear the change history for a particular item in the store, but this is a knock-on effect of the way he's using it.

An alternative approach might be for commit() to inject an item without wiping its change history, and then removing any change history entries that are redundant.

@internalfx
Copy link
Member

wants a way to clear the change history for a particular item in the store.

That is the very thing I want to do. Not sure what you mean by knock-on.

If commit just injects, but keeps the change history, it will be utterly useless to me. unless another alternate method is implemented.

@jmdobry
Copy link
Member Author

jmdobry commented Oct 22, 2015

clear the change history for a particular item in the store

That's exactly what DS#commit does

@internalfx
Copy link
Member

@jmdobry sorry, for the confusion. I was responding to @robertdp.

As I dive into doing full realtime with js-data, and with me using js-data's change tracking, I find that I need more tools to manipulate the change history of an object.

jmdobry added a commit that referenced this issue Oct 23, 2015
@jmdobry jmdobry added done and removed in progress labels Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants