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
wise-white•3mo ago
yeah sure! They're just fancy JS maps really so you can create them however would make sense
generous-apricotOP•3mo ago
Oh perfect, thanks for the quick response!
fair-rose•3mo 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
wise-white•3mo ago
does that key exist? You can log console.log(collection.keys())
fair-rose•3mo ago
hmm getting
<suspended>
Anyone know what this means? I assume doing something wrongwise-white•3mo ago
I don't know what <suspended> means — it's not something db returns
national-gold•3mo ago
Did you ever figure this out? I'm hitting this issue as well