Document
Object Hierarchy:
Description:
public class Document :
Object
Base class for a Couch DB Database/Document type.
To use this, create a subclass of Document, and override the database_name property to correspond to the existing database in CouchDB.
For each JSON property to be stored, create a property corresponding to an allowed type in couchdb-glib, namely, string, int, bool, or
double.
You may use the subclass by calling load_from_id(id) or save() to load and save documents from the document store.
Content:
Properties:
Creation methods:
Methods:
- public Database get_database ()
Retrieve an instance of Couchdb.Database, creates one if it is not
already loaded.
- public void load (Document document)
Load a returned document from Couchdb into this class instance. A
common use case is to create a constructor called .from_document(), and call the load() method from there.
- public bool load_from_id (string id) throws Error
Load a document from CouchDB using the unique ID into this class
instance. A common use case is to create a constructor called .from_id(), and call the load() method from there.
- public bool save () throws Error
Save the current instance data to CouchDB. Will update an existing
record if the ID matches. Will run the generate_id() method if the id is null.
- public virtual string generate_id ()
Method to override to generate a new ID per your conventions. To
automatically generate a random unique 40 character ID, return generate_random_sha_id().
- public string generate_random_sha_id ()
Convenience method to generate a random SHA1 ID. This is calculated
using a GLib-derived random number combined with the current time.
Inherited Members:
All known members inherited from class GLib.Object