-
Notifications
You must be signed in to change notification settings - Fork 62
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
Can property be a list of any object? #35
Comments
the simplest way would be to just add objects of that class to the list. if you want some kind of guard to make sure no one adds objects of other types to the list you could overwrite the setter, e.g.
|
But when you load a document, the list won't be cast appropriately. This is my current solution to that:
One of the things I like about couchdb vs. a relation database is the ability to store a one-to-many relationship within the document, without having to do a join. Do you think it would make sense to allow the property method to have a cardinality parameter, and encapsulate this pattern of casting a list of a type? Or am I opening a can of worms? |
yes it will, as long as the hashes in the document have the appropriate CouchRest has an option where you can say something like this:
This could be added to couch potato, so far nobody has bothered yet. |
Just in case anyone is following this, "property" was pulled out of CouchRest into the CouchRest Extended document gem, which in turn seems to have been superseded by CouchRest Model[1] I haven't looked into much, but it seems like CouchRest Model is leveraging a lot of the ActiveModel code from Rails3. Thanks for the lead Alexander. |
btw. so is couch potato. it uses callbacks and dirty tracking and is activemodel compliant. |
I see how, as long as the object implementes json_create and to_json, we can use it as a type of property.
What's the simplest way to have a property be a list of a particular type without implementing a boilerplate "ListofMyObject" class?
Thanks for any help.
M
The text was updated successfully, but these errors were encountered: