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

Add support for increment/decrement and array operations #22

Open
clintharris opened this issue Apr 8, 2021 · 0 comments
Open

Add support for increment/decrement and array operations #22

clintharris opened this issue Apr 8, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@clintharris
Copy link
Owner

clintharris commented Apr 8, 2021

Currently only "set" is supported.

  • There's no good way to do this without deviating from the IndexedDB API (which really only supports "set" ops)
  • It would involve modifying the oplog entry objects to specify the type of operation (set/increment/insert). Example:
    {
      hlcTime: '2021-01-24T13:23:14.203Z-0002-testnode',
      store: TODO_ITEMS_STORE,
      objectKey: defaultTodo.id,
      operation: 'increment' // 'decrement' | 'set' | 'arrayInsertAtIndex' | 'arraySetAtIndex' | 'arrayRemoveAtIndex', etc.
      prop: 'someCounter',
      value: -1
    }
    
  • Note that supporting array operations (i.e., insert, mutate at index, etc.) is not a pre-requisite. A feasible (and possibly simpler) solution is to normalize objects. Instead of { id: 1, things: [thing1, thing 2] }, create a separate object collection for things and associate them with the parent object.
@clintharris clintharris added the enhancement New feature or request label Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant