Filter/query data store
zzph opened this issue · comments
Hi there,
Firstly, this library is great.
Apologies if this is an obvious question- I’d like to filter the data before it’s sent to the store
For example, if I only wanted “completed” todos.
FWIW: I tired using “y-socket” to decode and then return filter but had no success. My thinking was to decode the entire store, then only send back specific data (or even indexes if a different data structure where data is in different “rooms” ie ws://…/key)
How I can filter the data before it arrives to the client? Can you offer any suggestions?
thanks
Hi @zzph!
The way SyncedStore is designed, is that always the entire "store" is synced with others. This is the overall concept that SyncedStore wants to achieve; the ability to sync entire data stores in a "local first" way.
Depending on your use case, you can probably do what you want in a different way:
- Sync everything, but only show filtered data
- Maybe the data shouldn't be synced indeed. In that case, the data should not be defined on a "syncedstore" but in a different state manager / store (i.e.: not on the SyncedStore store)
Hope this helps!