-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection2 and meteor collection design practice? #54
Comments
As an idea, if the meteor appoach differs from traditional orm mapping: May it be reasonable to define multiple schemas for a C2 collection, and let C2 maintain an additional field in each document that states its schema? |
New to noSQL the denormalization (data duplication) is a little uneasy to me. Is there maybe a useful pattern with collection2 (hooks to use?) to automatically update the other duplicates when one is updated? |
When there are collection changes necessary as a result of other collection changes, I've found it easiest to set up |
Ah, thank you for the pointer! That looks more meteoric and to work for insert/update/delete. I had only thought of autoForm hooks or collection-hooks so far. |
Found this example now (thanks to your search terms): https://stackoverflow.com/questions/12464451/in-meteor-how-to-update-one-db-field-when-another-field-changes Is that like what you meant? Would you think calling OtherCollection updates from autoValue functions would be viable alternative, to avoid the observe inefficienty and reactivity conflicts (like this one https://stackoverflow.com/questions/14250259/why-does-meteor-undo-changes-to-collections-nested-in-an-observer-method?rq=1), and to keep everything defined in the schema? |
Yes, that's essentially what I meant. The issue you reference is just a client-side thing, I believe. I usually define the observe on the server only, so it's never a simulation. I also don't believe observe callbacks are all that inefficient, as long as you write them wisely. I have a gut feeling against using |
I see, yeah same applies to deny functions. Of course you raise the question, what is a wise observe function? :-) Like the example that runs on every add and change, but acts only on field changes to avoid ping pong beween two collections that update each other. |
package isolate-value? |
I think wisdom for |
Ok, the new Meteor UI hasn't been on my beginner's radar yet. I found the observe things you mentioned are coverd in the docs, so that is good. Would you think the command queue method pattern (example from answer to 2. link above) could be a viable basis for transactions/rollback/undo in the relations handling etc.? |
You certainly could use custom methods as the answer in that link suggests. That will give you some limited transaction/rollback ability, but only if you write all of the logic yourself. I feel like rollbacks would be possible in server observes, too, but I can't recall if I've done it. You'd just have to write carefully to avoid infinite loops. In general, these are the exact questions we're hoping to solve with the C2 relationships development. You can test out Meteor UI by running your app from the |
Wow, you're really going for the complete solution with relations. I have thought about how to implement hierarchies/tags with c2 collections, and my current idea would be to use a separate collection to stores hierarchies with documents for arbitrary "namespaces" (e.g. user-tags, categories, user-types). C2 fields of tag/hierachy documents: Extra C2 fields on the data collection: Finally, a collection-hook/observe to update the matializedPaths in the data collection when the hierachy changes, and to update the refCounts in the hierarchy collection on ref changes. Does that sound reasonable? |
Hi there,
from reading about meteor I picked up a prelimnary list of ideas concerning collection design. I think it would be interesting to discuss them with regard to collection2 and relation handling:
However, separate collections can be handled easier when it comes to meteor publication/subscriptions.
And the templates (the dom model) can still join different queries together when rendered. As the data on the client is already reduced to a smaller subset, performance should be reasonably fast even with minimongo not yet supporting indexes.
The text was updated successfully, but these errors were encountered: