Comments (6)
@simonwh, my technique isn't ideal either. Exporting on every transaction causes performance issue. My workaround:
- Run the cozo wasm from a worker thread, so all the database I/O is isolated from the UI thread
- Export only upon user request, leading to data loss when user closes the app without saving.
In my opinion, a good continuous export implementation is a balancing act between the inevitable tradeoff between performance and data integrity. A few ideas I find useful:
- Use requestIdleCallback to let the browser pick a best moment to export but that won't work in Safari.
- Use some throttle and debounce techniques to reduce the export frequency
- Compare the stringified values and perform the export only when the value changes.
from cozo.
I am also interested in this. A few thoughts:
- Enabling the sqlite backend for wasm targets may be possible. See this PR to do so in rusqlite as an example.
- Could there be an addition to the current in-memory API so that you could optionally pass an impl of e.g. std::io::Write as an alternative location to write to? Then persisting to OPFS or localstorage would be relatively easy.
from cozo.
In the interim, I've been using json-based export/import relations against browser's origin private filesystem. It isn't the fastest solution but provides the functionality. Ideally I'd love to have the ability to load and save data in binary.
from cozo.
@chuanqisun We've done something similar, with in-memory cozo + localstorage (instead of origin private filesystem). We find it's working-ish. It's not super stable, and definitely not a long-term solution :) Would be interest to hear how you implemented it. Do you export/write file after every cozo operation? Or periodically? And then import on page load?
from cozo.
I would love browser based persistentence for local first applications.
I wonder if saving to ElectricSQL would be possible, enabling automatic sync to a back end as well?
from cozo.
I've been using sqlite in the browser via the wasm release , backed by OPFS (as mentioned above) and its awesome
i imagine for cozo to accomplish similar, the easiest route would be like @94bryanr suggested and get a sqlite backend for the wasm build ? instead of managing/creating your own persistence layer in the browser
but yeah regardless, browser persistence would be AMAZING
i have some recursive traversals over json blobs in sqlite to crudely accomplish traversals and bounded graph queries, but would vastly prefer an engine fit to purpose
from cozo.
Related Issues (20)
- Feature request: be able to build queries directly in rust, bypassing the script parser HOT 2
- What is the params argument for in the C library? HOT 1
- RFC: `cozo-migrate`, a simple migrations library for cozo HOT 1
- FTS: Field `k` is required for HNSW search
- Vector search error HOT 1
- Cannot include `#` character in a "raw string" HOT 7
- numerically equal float and int display as the same in REPL HOT 1
- Cozodb as a vector store for llama index or langchain
- CRDT based CozoDB cross device sync
- Aggregation returns 0 rows HOT 3
- Record types
- List methods don't work on Validity HOT 1
- Nested binding/matching
- cannot build cozo_c without -F graph-algo
- CRDT with Cozo
- JSON object key order is lost
- Wrong fields being used on index HOT 1
- Binary embeddings support HOT 1
- Seems * can not be used in FTS ? HOT 1
- Update sqlite version to 3.45 +
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cozo.