CouchdbSession

CouchdbSession

Synopsis

                    CouchdbSessionPrivate;
                    CouchdbSession;
                    CouchdbSessionClass;
CouchdbSession *    couchdb_session_new                 (const char *uri);
const char *        couchdb_session_get_uri             (CouchdbSession *session);
GSList *            couchdb_session_list_databases      (CouchdbSession *session,
                                                         GError **error);
void                couchdb_session_free_database_list  (GSList *dblist);
CouchdbDatabaseInfo * couchdb_session_get_database_info (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);
gboolean            couchdb_session_create_database     (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);
gboolean            couchdb_session_delete_database     (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);
gboolean            couchdb_session_compact_database    (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);
void                couchdb_session_listen_for_changes  (CouchdbSession *session,
                                                         const char *dbname);
void                couchdb_session_enable_authentication
                                                        (CouchdbSession *session,
                                                         CouchdbCredentials *credentials);
void                couchdb_session_disable_authentication
                                                        (CouchdbSession *session);
gboolean            couchdb_session_is_authentication_enabled
                                                        (CouchdbSession *session);
GSList *            couchdb_session_list_documents      (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);
GSList *            couchdb_session_get_all_documents   (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);
void                couchdb_session_free_document_list  (GSList *doclist);
gboolean            couchdb_session_replicate           (CouchdbSession *session,
                                                         const gchar *source,
                                                         const gchar *target,
                                                         gboolean continous,
                                                         GError **error);

Object Hierarchy

  GObject
   +----CouchdbSession

Properties

  "uri"                      gchar*                : Read / Write / Construct

Signals

  "authentication-failed"                          : Run Last
  "database-created"                               : Run Last
  "database-deleted"                               : Run Last
  "document-created"                               : Run Last
  "document-deleted"                               : Run Last
  "document-updated"                               : Run Last

Description

Details

CouchdbSessionPrivate

typedef struct _CouchdbSessionPrivate CouchdbSessionPrivate;


CouchdbSession

typedef struct _CouchdbSession CouchdbSession;


CouchdbSessionClass

typedef struct {
	GObjectClass parent_class;

	void (* authentication_failed) (CouchdbSession *session);

	void (* database_created) (CouchdbSession *session, const char *dbname);
	void (* database_deleted) (CouchdbSession *session, const char *dbname);

	void (* document_created) (CouchdbSession *session, const char *dbname, CouchdbDocument *document);
	void (* document_updated) (CouchdbSession *session, const char *dbname, CouchdbDocument *document);
	void (* document_deleted) (CouchdbSession *session, const char *dbname, const char *docid);
} CouchdbSessionClass;


couchdb_session_new ()

CouchdbSession *    couchdb_session_new                 (const char *uri);

Create a new CouchdbSession object, which is the entry point for operations on a CouchDB instance.

uri :

URI of the CouchDB instance to connect to

Returns :

A newly-created CouchdbSession object.

couchdb_session_get_uri ()

const char *        couchdb_session_get_uri             (CouchdbSession *session);

Retrieve the URI of the CouchDB instance a CouchdbSession object is bound to.

session :

Returns :

the URI of the CouchDB instance used by this CouchdbSession object.

couchdb_session_list_databases ()

GSList *            couchdb_session_list_databases      (CouchdbSession *session,
                                                         GError **error);

Retrieve the list of databases that exist in the CouchDB instance being used.

session :

error :

Placeholder for error information

Returns :

A list of strings containing the names of all the databases that exist in the CouchDB instance connected to. Once no longer needed, this list can be freed by calling couchdb_session_free_database_list.

couchdb_session_free_database_list ()

void                couchdb_session_free_database_list  (GSList *dblist);

Free the list of databases returned by couchdb_session_list_databases.

dblist :

A list of databases, as returned by couchdb_session_list_databases

couchdb_session_get_database_info ()

CouchdbDatabaseInfo * couchdb_session_get_database_info (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);

Retrieve information about a given database.

session :

dbname :

Name of the database for which to retrieve the information

error :

Placeholder for error information

Returns :

A CouchdbDatabaseInfo object, whose API can be used to retrieve all the information returned by CouchDB about this database.

couchdb_session_create_database ()

gboolean            couchdb_session_create_database     (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);

Create a new database on a CouchDB instance.

session :

dbname :

Name of the database to be created

error :

Placeholder for error information

Returns :

TRUE if successful, FALSE otherwise.

couchdb_session_delete_database ()

gboolean            couchdb_session_delete_database     (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);

Delete an existing database on a CouchDB instance.

session :

dbname :

Name of the database to be deleted

error :

Placeholder for error information

Returns :

TRUE if successful, FALSE otherwise.

couchdb_session_compact_database ()

gboolean            couchdb_session_compact_database    (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);

Compact the given database, which means removing outdated document revisions and deleted documents.

session :

dbname :

Name of the database to be compacted

error :

Placeholder for error information

Returns :

TRUE if successful, FALSE otherwise.

couchdb_session_listen_for_changes ()

void                couchdb_session_listen_for_changes  (CouchdbSession *session,
                                                         const char *dbname);

Setup a listener to get information about changes done to a specific database. Please note that changes done in the application using couchdb-glib will be notified without the need of calling this function. But if the application wants to receive notifications of changes done externally (by another application, or by any other means, like replication with a remote database), it needs to call this function.

For each change, one of the signals on the CouchdbSession object will be emitted, so applications just have to connect to those signals before calling this function.

session :

dbname :

Name of the database to poll changes for

couchdb_session_enable_authentication ()

void                couchdb_session_enable_authentication
                                                        (CouchdbSession *session,
                                                         CouchdbCredentials *credentials);

Enables authentication for the given CouchdbSession object. The authentication mechanism should be specificied when creating the CouchdbCredentials object.

session :

credentials :

A CouchdbCredentials object

couchdb_session_disable_authentication ()

void                couchdb_session_disable_authentication
                                                        (CouchdbSession *session);

Disables authentication for the given CouchdbSession object.

session :


couchdb_session_is_authentication_enabled ()

gboolean            couchdb_session_is_authentication_enabled
                                                        (CouchdbSession *session);

Gets whether the given CouchdbSession object has authentication enabled.

session :

Returns :

TRUE if authentication is enabled, FALSE otherwise.

couchdb_session_list_documents ()

GSList *            couchdb_session_list_documents      (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);

Retrieve the list of all documents from a database on a running CouchDB instance. For each document, a CouchdbDocumentInfo object is returned on the list, which can then be used for retrieving specific information for each document.

session :

A CouchdbSession object

dbname :

Name of the databases to retrieve documents from

error :

Placeholder for error information

Returns :

a list of CouchdbDocumentInfo objects, or NULL if there are none or there was an error (in which case the error argument will contain information about the error). Once no longer needed, the list should be freed by calling couchdb_session_free_document_list.

couchdb_session_get_all_documents ()

GSList *            couchdb_session_get_all_documents   (CouchdbSession *session,
                                                         const char *dbname,
                                                         GError **error);

Retrieve all documents from a database on a running CouchDB instance. For each document found in the database, a CouchdbDocument object is returned on the list, which represents the document's contents as found on the underlying database.

session :

dbname :

Name of the databases to retrieve documents from

error :

Placeholder for error information

Returns :

a list of CouchdbDocument objects, or NULL if there are none or there was an error (in which case the error argument will contain information about the error). Once no longer needed, the list should be freed by calling couchdb_session_free_document_list.

couchdb_session_free_document_list ()

void                couchdb_session_free_document_list  (GSList *doclist);

Free the list of documents returned by couchdb_session_list_documents.

doclist :

A list of CouchdbDocumentInfo objects, as returned by couchdb_session_list_documents

couchdb_session_replicate ()

gboolean            couchdb_session_replicate           (CouchdbSession *session,
                                                         const gchar *source,
                                                         const gchar *target,
                                                         gboolean continous,
                                                         GError **error);

Replicates a source database to another database, on the same CouchDB instance or on a remote instance.

If continous is FALSE, the replication will happen once, but if set to TRUE, CouchDB will listen to all changes made to the source database, and automatically replicate over any new docs as the come into the source to the target.

session :

source :

Source database

target :

Target database

continous :

Whether to replicate once or keep replicating

error :

Placeholder for error information

Returns :

TRUE if successful, FALSE otherwise, in which case the error parameter will be set to contain information about the error.

Property Details

The "uri" property

  "uri"                      gchar*                : Read / Write / Construct

Uri pointing to the host to connect to.

Default value: NULL

Signal Details

The "authentication-failed" signal

void                user_function                      (CouchdbSession *couchdbsession,
                                                        gpointer        user_data)           : Run Last

@:

The "database-created" signal

void                user_function                      (CouchdbSession *couchdbsession,
                                                        gchar          *arg1,
                                                        gpointer        user_data)           : Run Last

@: @:

The "database-deleted" signal

void                user_function                      (CouchdbSession *couchdbsession,
                                                        gchar          *arg1,
                                                        gpointer        user_data)           : Run Last

@: @:

The "document-created" signal

void                user_function                      (CouchdbSession *couchdbsession,
                                                        gchar          *arg1,
                                                        GObject        *arg2,
                                                        gpointer        user_data)           : Run Last

@: @: @:

The "document-deleted" signal

void                user_function                      (CouchdbSession *couchdbsession,
                                                        gchar          *arg1,
                                                        gchar          *arg2,
                                                        gpointer        user_data)           : Run Last

@: @: @:

The "document-updated" signal

void                user_function                      (CouchdbSession *couchdbsession,
                                                        gchar          *arg1,
                                                        GObject        *arg2,
                                                        gpointer        user_data)           : Run Last

@: @: @: