get and save unstructured document

1 view
Skip to first unread message

Klaus

unread,
Dec 18, 2009, 5:28:19 AM12/18/09
to CouchRest
Hi folks,

one reason for me to change to couchdb is to have documents where I
can add a field or change the name of a field without influencing
other documents on the same database.

I got a document with CouchRest::ExtendedDocument. The only fields
which where accessible as objects in Ruby where the fields which I
defined as property. As I don't know which fields are included in the
document I can't define them all as property.
Is there a way to get the structure of the document to use them all as
objects? I want to save them as easily as 'xxxxx.save'.

Thanks, Klaus (Germany)

PS: I am newbie with ruby on rails and couchdb! Coming from perl and
mysql.

Rue the Ghetto

unread,
Dec 19, 2009, 2:58:42 PM12/19/09
to couc...@googlegroups.com
Documents are extended from hashes. You can find all actual data names without the use of properties using the #keys method. So, doc.keys would return an array of keys for data elements. You can access the values for these keys in the normal hash way hash[key_name]. If you want to set new unstructured values on a document, you can add them in the normal hash way too.


--

You received this message because you are subscribed to the Google Groups "CouchRest" group.
To post to this group, send email to couc...@googlegroups.com.
To unsubscribe from this group, send email to couchrest+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchrest?hl=en.



Reply all
Reply to author
Forward
0 new messages