![]() |
![]() |
![]() |
Reference Manual for CouchDB GLib Bindings | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
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;
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. |
const char * couchdb_document_get_id (CouchdbDocument *document
);
Retrieve the unique ID of the given document.
|
A CouchdbDocument object |
Returns : |
The unique ID of the given document. |
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.
|
A CouchdbDocument object |
|
New unique ID for the given document. |
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.
|
A CouchdbDocument object |
Returns : |
Revision of the given document. |
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.
|
A CouchdbDocument object |
|
String specifying the revision to set the document to |
gboolean couchdb_document_has_field (CouchdbDocument *document
,const char *field
);
Check whether the given document has a field with a specific name.
|
A CouchdbDocument object |
|
Name of the field to check existence for in the document |
Returns : |
TRUE if the field exists in the document, FALSE if not. |
void couchdb_document_remove_field (CouchdbDocument *document
,const char *field
);
Remove a field from the given document.
|
A CouchdbDocument object |
|
Name of the field to remove from the document |
GSList * couchdb_document_get_field_names (CouchdbDocument *document
);
Retrieve the list of fields contained in the given CouchdbDocument.
|
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. |
GType couchdb_document_get_field_type (CouchdbDocument *document
,const char *field
);
Get the value type of the given CouchdbDocument's field.
|
A CouchdbDocument object |
|
Name of the field to get type |
Returns : |
Type of the field. |
CouchdbArrayField * couchdb_document_get_array_field (CouchdbDocument *document
,const char *field
);
Retrieve the value of an array field from the given document.
|
A CouchdbDocument object |
|
Name of the field to retrieve |
Returns : |
The value of the given 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.
|
A CouchdbDocument object |
|
Name of the field to set |
|
Value to set the field to |
gboolean couchdb_document_get_boolean_field (CouchdbDocument *document
,const char *field
);
Retrieve the value of a boolean field from the given document.
|
A CouchdbDocument object |
|
Name of the field to retrieve |
Returns : |
The value of the given 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.
|
A CouchdbDocument object |
|
Name of the field to set |
|
Value to set the field to |
gint couchdb_document_get_int_field (CouchdbDocument *document
,const char *field
);
Retrieve the value of an integer field from the given document.
|
A CouchdbDocument object |
|
Name of the field to retrieve |
Returns : |
The value of the given integer 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.
|
A CouchdbDocument object |
|
Name of the field to set |
|
Value to set the field to |
gdouble couchdb_document_get_double_field (CouchdbDocument *document
,const char *field
);
Retrieve the value of a decimal number field from the given document.
|
A CouchdbDocument object |
|
Name of the field to retrieve |
Returns : |
The value of the given decimal number 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.
|
A CouchdbDocument object |
|
Name of the field to set |
|
Value to set the field to |
const char * couchdb_document_get_string_field (CouchdbDocument *document
,const char *field
);
Retrieve the value of a string field from the given document.
|
A CouchdbDocument object |
|
Name of the field to retrieve |
Returns : |
The value of the given 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.
|
A CouchdbDocument object |
|
Name of the field to set |
|
Value to set the field to |
CouchdbStructField * couchdb_document_get_struct_field (CouchdbDocument *document
,const char *field
);
Retrieve the value of a struct field from the given document.
|
A CouchdbDocument object |
|
Name of the field to retrieve |
Returns : |
The value of the given 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.
|
A CouchdbDocument object |
|
Name of the field to set |
|
Value to set the field to |
char * couchdb_document_to_string (CouchdbDocument *document
);
Convert the given CouchdbDocument to a JSON string.
|
A CouchdbDocument object |
Returns : |
A string containing the given document in JSON format. |
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.
|
A CouchdbDocument object |
Returns : |
The record type of the given document. |
void couchdb_document_set_record_type (CouchdbDocument *document
,const char *record_type
);
Set the record type of the given document.
|
A CouchdbDocument object |
|
Record type to set the document to |
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.
|
A CouchdbDocument object |
Returns : |
A CouchdbStructField containing the value of the application annotations for the given document. |
void couchdb_document_set_application_annotations (CouchdbDocument *document
,CouchdbStructField *annotations
);
Set the application annotations for the given document.
|
A CouchdbDocument object |
|
A CouchdbStructField with the contents of the application_annotations field. |
#define COUCHDB_RECORD_TYPE_CONTACT "http://www.freedesktop.org/wiki/Specifications/desktopcouch/contact"
#define COUCHDB_RECORD_TYPE_TASK "http://www.freedesktop.org/wiki/Specifications/desktopcouch/task"
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
|
A CouchdbDocument object |
Returns : |
TRUE if the document represents a contact, FALSE otherwise. |
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
|
A CouchdbDocument object |
Returns : |
TRUE if the document represents a task, FALSE otherwise. |
"database"
property"database" CouchdbDatabase* : Read / Write / Construct
Database from which this document was retrieved/saved.