CouchdbDocument

CouchdbDocument

Synopsis

                    CouchdbDocument;
                    CouchdbDocumentClass;
CouchdbDocument *   couchdb_document_new                (void);
const char *        couchdb_document_get_id             (CouchdbDocument *document);
void                couchdb_document_set_id             (CouchdbDocument *document,
                                                         const char *id);
const char *        couchdb_document_get_revision       (CouchdbDocument *document);
void                couchdb_document_set_revision       (CouchdbDocument *document,
                                                         const char *revision);
gboolean            couchdb_document_has_field          (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_remove_field       (CouchdbDocument *document,
                                                         const char *field);
GSList *            couchdb_document_get_field_names    (CouchdbDocument *document);
GType               couchdb_document_get_field_type     (CouchdbDocument *document,
                                                         const char *field);
CouchdbArrayField * couchdb_document_get_array_field    (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_set_array_field    (CouchdbDocument *document,
                                                         const char *field,
                                                         CouchdbArrayField *value);
gboolean            couchdb_document_get_boolean_field  (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_set_boolean_field  (CouchdbDocument *document,
                                                         const char *field,
                                                         gboolean value);
gint                couchdb_document_get_int_field      (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_set_int_field      (CouchdbDocument *document,
                                                         const char *field,
                                                         gint value);
gdouble             couchdb_document_get_double_field   (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_set_double_field   (CouchdbDocument *document,
                                                         const char *field,
                                                         gdouble value);
const char *        couchdb_document_get_string_field   (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_set_string_field   (CouchdbDocument *document,
                                                         const char *field,
                                                         const char *value);
CouchdbStructField * couchdb_document_get_struct_field  (CouchdbDocument *document,
                                                         const char *field);
void                couchdb_document_set_struct_field   (CouchdbDocument *document,
                                                         const char *field,
                                                         CouchdbStructField *value);
char *              couchdb_document_to_string          (CouchdbDocument *document);
const char *        couchdb_document_get_record_type    (CouchdbDocument *document);
void                couchdb_document_set_record_type    (CouchdbDocument *document,
                                                         const char *record_type);
CouchdbStructField * couchdb_document_get_application_annotations
                                                        (CouchdbDocument *document);
void                couchdb_document_set_application_annotations
                                                        (CouchdbDocument *document,
                                                         CouchdbStructField *annotations);
#define             COUCHDB_RECORD_TYPE_CONTACT
#define             COUCHDB_RECORD_TYPE_TASK
gboolean            couchdb_document_is_contact         (CouchdbDocument *document);
gboolean            couchdb_document_is_task            (CouchdbDocument *document);
                    CouchdbDocumentPrivate;

Object Hierarchy

  GObject
   +----CouchdbDocument

Properties

  "database"                 CouchdbDatabase*      : Read / Write / Construct

Description

Details

CouchdbDocument

typedef struct _CouchdbDocument CouchdbDocument;


CouchdbDocumentClass

typedef struct {
	GObjectClass parent_class;
} CouchdbDocumentClass;


couchdb_document_new ()

CouchdbDocument *   couchdb_document_new                (void);

Create an empty CouchdbDocument object, which can then be populated with data and added to a database.

Returns :

A newly-created CouchdbDocument object, with no data on it.

couchdb_document_get_id ()

const char *        couchdb_document_get_id             (CouchdbDocument *document);

Retrieve the unique ID of the given document.

document :

A CouchdbDocument object

Returns :

The unique ID of the given document.

couchdb_document_set_id ()

void                couchdb_document_set_id             (CouchdbDocument *document,
                                                         const char *id);

Set the unique ID for a given document.

This usually is not needed by calling applications, unless they want to force IDs on the CouchDB documents created/updated for some reason, like compatibility with 3rd party applications. In most cases, the autogenerated IDs from CouchDB when new documents are created (see couchdb_document_put) should be ok for most applications.

document :

A CouchdbDocument object

id :

New unique ID for the given document.

couchdb_document_get_revision ()

const char *        couchdb_document_get_revision       (CouchdbDocument *document);

Retrieve the revision of a given document.

CouchDB does not overwrite updated documents in place, instead it creates a new document at the end of the database file, with the same ID but a new revision.

Document revisions are used for optimistic concurrency control and applications should not rely on document revisions for any other purpose than concurrency control.

document :

A CouchdbDocument object

Returns :

Revision of the given document.

couchdb_document_set_revision ()

void                couchdb_document_set_revision       (CouchdbDocument *document,
                                                         const char *revision);

Set the revision of the given document. This should never be used by applications, unless they really know what they are doing, since using a wrong revision string will confuse CouchDB when doing updates to the document.

document :

A CouchdbDocument object

revision :

String specifying the revision to set the document to

couchdb_document_has_field ()

gboolean            couchdb_document_has_field          (CouchdbDocument *document,
                                                         const char *field);

Check whether the given document has a field with a specific name.

document :

A CouchdbDocument object

field :

Name of the field to check existence for in the document

Returns :

TRUE if the field exists in the document, FALSE if not.

couchdb_document_remove_field ()

void                couchdb_document_remove_field       (CouchdbDocument *document,
                                                         const char *field);

Remove a field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to remove from the document

couchdb_document_get_field_names ()

GSList *            couchdb_document_get_field_names    (CouchdbDocument *document);

Retrieve the list of fields contained in the given CouchdbDocument.

document :

A CouchdbDocument object

Returns :

A list of strings containing the names of all the fields contained in the given CouchdbDocument object. When no longer needed, the list should be freed by calling g_slist_free.

couchdb_document_get_field_type ()

GType               couchdb_document_get_field_type     (CouchdbDocument *document,
                                                         const char *field);

Get the value type of the given CouchdbDocument's field.

document :

A CouchdbDocument object

field :

Name of the field to get type

Returns :

Type of the field.

couchdb_document_get_array_field ()

CouchdbArrayField * couchdb_document_get_array_field    (CouchdbDocument *document,
                                                         const char *field);

Retrieve the value of an array field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to retrieve

Returns :

The value of the given array field.

couchdb_document_set_array_field ()

void                couchdb_document_set_array_field    (CouchdbDocument *document,
                                                         const char *field,
                                                         CouchdbArrayField *value);

Set the value of an array field in the given document.

document :

A CouchdbDocument object

field :

Name of the field to set

value :

Value to set the field to

couchdb_document_get_boolean_field ()

gboolean            couchdb_document_get_boolean_field  (CouchdbDocument *document,
                                                         const char *field);

Retrieve the value of a boolean field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to retrieve

Returns :

The value of the given boolean field.

couchdb_document_set_boolean_field ()

void                couchdb_document_set_boolean_field  (CouchdbDocument *document,
                                                         const char *field,
                                                         gboolean value);

Set the value of a boolean field in the given document.

document :

A CouchdbDocument object

field :

Name of the field to set

value :

Value to set the field to

couchdb_document_get_int_field ()

gint                couchdb_document_get_int_field      (CouchdbDocument *document,
                                                         const char *field);

Retrieve the value of an integer field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to retrieve

Returns :

The value of the given integer field.

couchdb_document_set_int_field ()

void                couchdb_document_set_int_field      (CouchdbDocument *document,
                                                         const char *field,
                                                         gint value);

Set the value of an integer field in the given document.

document :

A CouchdbDocument object

field :

Name of the field to set

value :

Value to set the field to

couchdb_document_get_double_field ()

gdouble             couchdb_document_get_double_field   (CouchdbDocument *document,
                                                         const char *field);

Retrieve the value of a decimal number field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to retrieve

Returns :

The value of the given decimal number field.

couchdb_document_set_double_field ()

void                couchdb_document_set_double_field   (CouchdbDocument *document,
                                                         const char *field,
                                                         gdouble value);

Set the value of a decimal number field in the given document.

document :

A CouchdbDocument object

field :

Name of the field to set

value :

Value to set the field to

couchdb_document_get_string_field ()

const char *        couchdb_document_get_string_field   (CouchdbDocument *document,
                                                         const char *field);

Retrieve the value of a string field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to retrieve

Returns :

The value of the given string field.

couchdb_document_set_string_field ()

void                couchdb_document_set_string_field   (CouchdbDocument *document,
                                                         const char *field,
                                                         const char *value);

Set the value of a string field in the given document.

document :

A CouchdbDocument object

field :

Name of the field to set

value :

Value to set the field to

couchdb_document_get_struct_field ()

CouchdbStructField * couchdb_document_get_struct_field  (CouchdbDocument *document,
                                                         const char *field);

Retrieve the value of a struct field from the given document.

document :

A CouchdbDocument object

field :

Name of the field to retrieve

Returns :

The value of the given struct field.

couchdb_document_set_struct_field ()

void                couchdb_document_set_struct_field   (CouchdbDocument *document,
                                                         const char *field,
                                                         CouchdbStructField *value);

Set the value of a struct field in the given document.

document :

A CouchdbDocument object

field :

Name of the field to set

value :

Value to set the field to

couchdb_document_to_string ()

char *              couchdb_document_to_string          (CouchdbDocument *document);

Convert the given CouchdbDocument to a JSON string.

document :

A CouchdbDocument object

Returns :

A string containing the given document in JSON format.

couchdb_document_get_record_type ()

const char *        couchdb_document_get_record_type    (CouchdbDocument *document);

Retrieve the record type of the given document. Record types are special fields in the CouchDB documents, used in Desktopcouch, to identify standard records. All supported record types are listed at http://www.freedesktop.org/wiki/Specifications/desktopcouchFormats.

document :

A CouchdbDocument object

Returns :

The record type of the given document.

couchdb_document_set_record_type ()

void                couchdb_document_set_record_type    (CouchdbDocument *document,
                                                         const char *record_type);

Set the record type of the given document.

document :

A CouchdbDocument object

record_type :

Record type to set the document to

couchdb_document_get_application_annotations ()

CouchdbStructField * couchdb_document_get_application_annotations
                                                        (CouchdbDocument *document);

Retrieve the application annotations for the given document.

Application annotations is a special field (named "application_annotations"), used in Desktopcouch to allow applications to set values on standard documents (as defined at http://www.freedesktop.org/wiki/Specifications/desktopcouchFormats) that are not part of the standard, but still needed by the application.

document :

A CouchdbDocument object

Returns :

A CouchdbStructField containing the value of the application annotations for the given document.

couchdb_document_set_application_annotations ()

void                couchdb_document_set_application_annotations
                                                        (CouchdbDocument *document,
                                                         CouchdbStructField *annotations);

Set the application annotations for the given document.

document :

A CouchdbDocument object

annotations :

A CouchdbStructField with the contents of the application_annotations field.

COUCHDB_RECORD_TYPE_CONTACT

#define COUCHDB_RECORD_TYPE_CONTACT "http://www.freedesktop.org/wiki/Specifications/desktopcouch/contact"


COUCHDB_RECORD_TYPE_TASK

#define COUCHDB_RECORD_TYPE_TASK "http://www.freedesktop.org/wiki/Specifications/desktopcouch/task"


couchdb_document_is_contact ()

gboolean            couchdb_document_is_contact         (CouchdbDocument *document);

Check whether the given document represents a contact record, as specified at http://www.freedesktop.org/wiki/Specifications/desktopcouch/contact

document :

A CouchdbDocument object

Returns :

TRUE if the document represents a contact, FALSE otherwise.

couchdb_document_is_task ()

gboolean            couchdb_document_is_task            (CouchdbDocument *document);

Check whether the given document represents a contact record, as specified at http://www.freedesktop.org/wiki/Specifications/desktopcouch/task

document :

A CouchdbDocument object

Returns :

TRUE if the document represents a task, FALSE otherwise.

CouchdbDocumentPrivate

typedef struct _CouchdbDocumentPrivate CouchdbDocumentPrivate;

Property Details

The "database" property

  "database"                 CouchdbDatabase*      : Read / Write / Construct

Database from which this document was retrieved/saved.