Offix Datastore provides react hooks for CRUD operations and subscription.
For a quick start see sample react app.
useSave hook provides a lazy
a loading indicator
isLoading and an
error state variable.
save function accepts the input and returns a promise of the save result.
You can query using this hook, with or without filters or id. When no filter or id is supplied all the data is returned.
Query using a filter;
Query by id;
You can also subscribe to more changes using the
This hook provides a lazy
query function. The
query function accepts
a filter, an id or nothing, in which case, all documents are returned.
query function also returns a
that you can use to subscribe to changes for that query.
useUpdate works just like the
The only difference is that the input to the
update function must have its primary key defined.
update function accepts an optional
upsert parameter(which is
false by default) that can be used to
saveOrUpdate operation instead of an
You can subscribe to specific events and receive changes data using this hook.
We listen for updates to the task and render them. The
useSubscription is the data carried by the change event.