creating an empty collection and ready state
I'm having this issue where i'm basically creating a collection from another one, for instance
the objective of this is to populate this collection with the data from the other, and then via an SSE, start updating those elements as necessary. basically this collection does not do a sync of any type.
however, with this i'm getting an error:
when trying to write on to it. any ideas?
I think I can circumvent this whole thing but I'm wondering if this might be a bug?
9 Replies
evident-indigo•3w ago
The sub collections can just be local collections to simplify this. Query collections are just if you're actually fetching data generally
sunny-greenOP•3w ago
oh, that makes sense! I'll try them out. the docs seem to be dead though:
https://tanstack.com/db/latest/docs/overview/collections/local-only-collection
I did something like:
which seems to fail for me as there's no
utils.writeUpsert on itevident-indigo•3w ago
fixed the link https://github.com/TanStack/db/pull/788
GitHub
Fix broken TanStack documentation links by KyleAMathews · Pull Req...
Changed hash-based links (#localstoragecollection and #localonlycollection) to proper file path links (./collections/local-storage-collection.md and ./collections/local-only-collection.md) in the o...
evident-indigo•3w ago
LocalOnly Collection | TanStack DB Docs
LocalOnly Collection LocalOnly collections are designed for in-memory client data or UI state that doesn't need to persist across browser sessions or sync across tabs. Overview The localOnlyCollection...
sunny-greenOP•3w ago
thank you! I see there's
insert, but no upsert. I can probably sidestep that but is there anything wrong with using a queryCollection even though i'm using it as local?
seems like I got it to work when I actually did a subscription to that collectionevident-indigo•3w ago
It might work to use query collection but you're fighting against the grain a bit
sunny-greenOP•3w ago
I see, would be great for collections to share a common interface for utils, really missing that upsert
evident-indigo•3w ago
upsert is just (if collection.has(id) { collection.update() } else { collection.insert() }
make your own!
upsert can have different semantics so it's not going to be added to the main collection api
sunny-greenOP•3w ago
oh I see -- I would've assumed they all shared the same 'core' db part
but that was a big assumption I guess