Keep reactivity between collections


#1

I have a collection products, that has all the products of my application, in them you can do many filters and sorting.
The companies of my app can select multiple products and assign a price they deem.

how I keep the products that a company select so you can keep filters and sorts and also that the original product changes affect others without lose performance?


#2

I have to resave all the product again?, how do I maintain the changes then? :'C


#3

I am not sure if I understand correctly, but some “view” you can save separately by creating document which have relevant fields like search strings, sort orders, etc . Save it in different collection with link to user id etc

If there is change to product itself, all clients should reflect it in real time if you are using publish/subscribe the meteor way.


#4

then I should save the relevant information from collection A in the collection B?
but if the collection A changed how I keep the changes also in the collection B?


#5

I never said to save any copy from A, but you kinda hard described what you are trying to do.

If company selects some product, you can take their _id’s, assign price, you can save them as document in another collection, which will consist of price + array of product _ids + _id of company record. So it will link to all needed data to reconstruct it etc…


#6

What is kinda SQL way(the methods above), but you can also add array of these to company record itself, so it will be more company centric.

Or assign to every product array of these requested prices paired with company _ids which asked them

Or both, as nosql way is also to keep these in more places if it is easier for you to query them depending from which end you are starting to construct your view :smiley:


#7

shock thanks for the answers, I’ll take me a while to think to reach the best solution