feature: emit events

This commit is contained in:
Andy Burke 2025-07-01 19:14:18 -07:00
parent 0d0f399cc2
commit 3214d17b80
7 changed files with 460 additions and 18 deletions

View file

@ -11,6 +11,8 @@ optimization to the filesystem layer.
`collection.delete(T)` - removes an object from the system and the disk
`collection.all([options])` - iterate over all objects
`collection.find(criteria[, options])` - find all objects that match the criteria *that have an index*
`collection.on(event, callback)` - set a callback for the given event (create,update,get,delete,write,index,all,find)
`collection.off(event, callback)` - remove a callback for the given event
### Example
@ -157,6 +159,27 @@ for browsing the data as a human.
TODO: index everything into a sqlite setup as well? would give a way to run
SQL against data still stored on disk in a nicely human browsable format.
## Environment Variables
| variable | description |
| --------------------------- | ----------------------------------------------- |
| FSDB_ROOT | controls the root directory, default: ./.fsdb |
| FSDB_PERF | set to true for performance tracking |
| FSDB_LOG_EVENTS | set to true to log the events system |
## TODO
- [ ] make all()/find() return something like { file_info, entry: { private data = undefined; load() => { data = data ?? await Deno.readTextFile(this.file_info.path); return data; } } }
- [ ] make all()/find() return something like
```
{
file_info,
entry: {
private data = undefined;
load() => {
data = data ?? await Deno.readTextFile(this.file_info.path);
return data;
}
}
}
```