[couchdb-glib/wip/query-response] add missing couchdb_session_has_database function



commit 63b1fd951ce94b15b51e5720c8c21dcbdb652e1d
Author: Krzysztof Klimonda <kklimonda syntaxhighlighted com>
Date:   Wed Jan 19 14:30:35 2011 +0100

    add missing couchdb_session_has_database function

 couchdb-glib/couchdb-session.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/couchdb-glib/couchdb-session.c b/couchdb-glib/couchdb-session.c
index 720d5e3..15b1800 100644
--- a/couchdb-glib/couchdb-session.c
+++ b/couchdb-glib/couchdb-session.c
@@ -549,6 +549,34 @@ couchdb_session_get_database (CouchdbSession *session, const char *dbname, GErro
 }
 
 /**
+ * couchdb_session_has_database:
+ * @session: A #CouchdbSession object
+ * @dbname: Name of the database to search for
+ *
+ * Checks if there is a database with the given name on CouchDB server.
+ *
+ * Return value: %TRUE, or %FALSE depending on whether the database
+ * with the given name exists.
+ */
+gboolean
+couchdb_session_has_database (CouchdbSession *session, const char *dbname)
+{
+	JsonObject *dbinfo;
+
+	g_return_val_if_fail (COUCHDB_IS_SESSION (session), FALSE);
+	g_return_val_if_fail (dbname != NULL, FALSE);
+
+	dbinfo = couchdb_session_get_database_info (session, dbname, NULL);
+	if (dbinfo != NULL) {
+		json_object_unref (dbinfo);
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+/**
  * couchdb_session_create_database:
  * @session: A #CouchdbSession object
  * @dbname: Name of the database to retrieve



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]