Comments (8)
My new stake is: Add schema adapters for the following libraries
- The mainstream one
- Everyone knows how to use it
- Simple
- Zero learning curve
- The hottest one
- The most feature rich
- The one used the most in Local First libraries (for a reason):
- LiveStore
- ElectricSQL
- DXOS
- Jazz
- Automerge
- Evolu
Social proof:
https://x.com/schickling/status/1761707815016559048
Since Effect Schema has became the defacto standard for the data layer in LoFi libraries, I believe it to be a no-brainer to add support for it.
Star History
Effect 3.0 GA has just been released so its getting traction.
from tinybase.
OK, I think we could have a go at this, though of course it will be a limited dialect of what most of these other schemas are capable of. One question is whether this should be a dev-/build-time process (to create a TinyBase schema from these others) or something that can just be handled at runtime. I need to get familiar with all of these and what common pattern might work. (Hence I'm going to say it'll be after 5.0...!)
from tinybase.
Did you see this? https://tinybase.org/guides/schemas-and-persistence/schema-based-typing/
When you use the 'with-schemas' versions of the definitions, you get inferred APIs based on the JSON.
Let me know if that is what you had in mind or how it could be improved!
from tinybase.
Ok, I'll try that one! Thanks
from tinybase.
Assuming that's an OK approach, can I close out this issue?
from tinybase.
Ok! It worked :)
However I was thinking of making the schemas more "modern" and "common" along most used practices around the corner.
There are multiple ways to write a schema in TS, and it may be a good idea to support multiple ways since it is common for the developer to prefer the syntax that one is already using in the project.
For instance, Drizzle supports three different schema tastes:
So it might make sense to support all, or some of them.
Also, considering that TinyBase schema types are very simple, perhaps doing the schema typing as Typia or Deepkit might work well enough.
So instead of having this:
const tablesSchema = {
pets: {
species: {type: 'string'}
sold: {type: 'boolean'}
total: {type: 'number'}
},
} as const;
We could just have:
const tablesSchema = {
pets: {
species: string
sold: boolean
total: number
},
} as const;
from tinybase.
Providing zod
integration would be much appreciated. Not only is it probably the most feature-rich and most popular validation framework, but many automatic FOSS form kits (e.g superforms, formsnap) exist that make it easy to use the same schema seamlessly on the front- and backend, streamlining the whole application code and cutting overhead tremendously.
from tinybase.
One question is whether this should be a dev-/build-time process (to create a TinyBase schema from these others) or something that can just be handled at runtime. I need to get familiar with all of these and what common pattern might work.
Looking at how other libraries solve the problem might be a hint:
Drizzle creates a runtime extension for each schema validation library.
https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-zod
https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-typebox
If performance becomes an issue, a dev/build time process can be added later.
from tinybase.
Related Issues (20)
- VSCode Auto Import not working correctly HOT 5
- IndexedDB integration for service workers HOT 2
- Page of community apps and demos
- First party CRDT support HOT 1
- expo-sqlite-next-persister not working HOT 3
- Create of IndexedDB persister is slow when database doesn't exist HOT 7
- useCreate hooks do not work when React.StrictMode is enabled HOT 4
- PowerSync support HOT 2
- Persists Tinybase to Turso's SQLite Edge HOT 8
- StoreInspector doesn't seem to work on API generated Providers HOT 1
- Develop a Vite plugin for getStoreApi HOT 2
- Consider using Bun for the development of TinyBase itself HOT 1
- Persist TinyBase to Astro DB
- Support TS `moduleResolution: node16` HOT 5
- Loro CRDT Addition
- 'Pagination' for SQLite persistence
- Extra persister events (start + finish) HOT 1
- Hermes error with Expo 50 + Tinybase v5 beta HOT 11
- ESlint errors from import/no-unresolved HOT 9
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 tinybase.