-
-
Notifications
You must be signed in to change notification settings - Fork 8
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 hooks and deprecate batch
, put
& del
events
#45
Commits on Oct 30, 2022
-
Adds postopen, prewrite and newsub hooks that allow userland "hook functions" to customize behavior of the database. See README for details. A quick example: ```js db.hooks.prewrite.add(function (op, batch) { if (op.type === 'put') { batch.add({ type: 'put', key: op.value.foo, value: op.key, sublevel: fooIndex }) } }) ``` More generally, this is a move towards "renewed modularity". Our ecosystem is old and many modules no longer work because they had no choice but to monkeypatch database methods, of which the signature has changed since then. So in addition to hooks, this: - Introduces a new `write` event that is emitted on `db.batch()`, `db.put()` and `db.del()` and has richer data: userland options, encoded data, keyEncoding and valueEncoding. The `batch`, `put` and `del` events are now deprecated and will be removed in a future version. Related to Level/level#222. - Restores support of userland options on batch operations. In particular, to copy options in `db.batch(ops, options)` to ops, allowing for code like `db.batch(ops, { ttl: 123 })` to apply a default userland `ttl` option to all ops. No breaking changes, yet. Using hooks means opting-in to new behaviors (like the new write event) and disables some old behaviors (like the deprecated events). Later on we can make those the default behavior, regardless of whether hooks are used. TODO: benchmarks, tests and optionally some light refactoring. Closes Level/community#44.
Configuration menu - View commit details
-
Copy full SHA for 80e98c0 - Browse repository at this point
Copy the full SHA 80e98c0View commit details
Commits on Nov 1, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 75c75e2 - Browse repository at this point
Copy the full SHA 75c75e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for b2ac91f - Browse repository at this point
Copy the full SHA b2ac91fView commit details
Commits on Nov 2, 2022
-
Configuration menu - View commit details
-
Copy full SHA for abafd87 - Browse repository at this point
Copy the full SHA abafd87View commit details -
Configuration menu - View commit details
-
Copy full SHA for ab8b7fb - Browse repository at this point
Copy the full SHA ab8b7fbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 141da9e - Browse repository at this point
Copy the full SHA 141da9eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 59ed91f - Browse repository at this point
Copy the full SHA 59ed91fView commit details
Commits on Nov 3, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 9036d3f - Browse repository at this point
Copy the full SHA 9036d3fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e2aacb - Browse repository at this point
Copy the full SHA 0e2aacbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0fdfb67 - Browse repository at this point
Copy the full SHA 0fdfb67View commit details -
And simplify existing tests by first checking when the hook function is called, i.e. after db has opened.
Configuration menu - View commit details
-
Copy full SHA for 94279fb - Browse repository at this point
Copy the full SHA 94279fbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 58239b0 - Browse repository at this point
Copy the full SHA 58239b0View commit details
Commits on Nov 5, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 712c990 - Browse repository at this point
Copy the full SHA 712c990View commit details -
Configuration menu - View commit details
-
Copy full SHA for aa9bdab - Browse repository at this point
Copy the full SHA aa9bdabView commit details -
Configuration menu - View commit details
-
Copy full SHA for 88c3861 - Browse repository at this point
Copy the full SHA 88c3861View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.