are collections meant to be singletons?
Hi friends,
Just getting my feet wet here and thinking about the multi-tenant use case where we might want to have a query function that, for example, fetchs todos for a specific organization.
I think the obvious solution here is to create a factory that takes the
orgId
as an argument. However, from what I can see in the docs, collections seem to be something that is meant created once at application start. Is this true? or is it fine to dynamically create collections at runtime based on params ?7 Replies
foreign-sapphire•3w ago
yeah sure! They're just fancy JS maps really so you can create them however would make sense
ratty-blushOP•3w ago
Oh perfect, thanks for the quick response!
optimistic-gold•3w ago
I'm having a similar question. Does something like this work in react? Am I supposed to pass in the query client I get from a hook? This feels wrong so not sure.
It's working but getting this error when I try to update or insert
CollectionOperationError: The key "019936cf-b739-765a-8b9d-d422272baab9" was passed to update but an object for this key was not found in the collection
foreign-sapphire•3w ago
does that key exist? You can log console.log(collection.keys())
optimistic-gold•3w ago
hmm getting
<suspended>
Anyone know what this means? I assume doing something wrongforeign-sapphire•3w ago
I don't know what <suspended> means — it's not something db returns
optimistic-gold•3w ago
Did you ever figure this out? I'm hitting this issue as well