[couchdb-glib] Make couchdb_database_get_all_documents know about design documents



commit 7830ac9c127c4785bb41a48a0cef91443795dda9
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Mon May 24 17:33:02 2010 +0200

    Make couchdb_database_get_all_documents know about design documents

 .gitignore                             |   17 +++++++++++++++++
 couchdb-glib/couchdb-database.c        |   20 +++++++++++++-------
 couchdb-glib/couchdb-design-document.h |    4 +++-
 3 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 08929b3..16e1ca9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,3 +65,20 @@ doc/reference/tmpl/
 doc/reference/xml/
 bindings/mono/couchdb-glib-sharp.dll.config
 bindings/mono/*.dll
+bindings/mono/CouchdbArrayField.cs
+bindings/mono/CouchdbCredentials.cs
+bindings/mono/CouchdbCredentialsType.cs
+bindings/mono/CouchdbDatabase.cs
+bindings/mono/CouchdbDatabaseInfo.cs
+bindings/mono/CouchdbDesignDocument.cs
+bindings/mono/CouchdbDocument.cs
+bindings/mono/CouchdbDocumentInfo.cs
+bindings/mono/CouchdbSession.cs
+bindings/mono/CouchdbStructField.cs
+bindings/mono/DatabaseCreatedHandler.cs
+bindings/mono/DatabaseDeletedHandler.cs
+bindings/mono/DocumentCreatedHandler.cs
+bindings/mono/DocumentDeletedHandler.cs
+bindings/mono/DocumentUpdatedHandler.cs
+bindings/mono/ObjectManager.cs
+bindings/mono/couchdb-glib-api.xml
diff --git a/couchdb-glib/couchdb-database.c b/couchdb-glib/couchdb-database.c
index ab3100c..5cbc2e7 100644
--- a/couchdb-glib/couchdb-database.c
+++ b/couchdb-glib/couchdb-database.c
@@ -374,19 +374,25 @@ couchdb_database_get_all_documents (CouchdbDatabase *database, GError **error)
 		gint i;
 		for (i = 0; i < json_array_get_length (rows); i++) {
 			JsonObject *obj;
-			CouchdbDocument *document;
+			CouchdbDocument *document = NULL;
 
 			obj = json_array_get_object_element (rows, i);
 			if (!obj)
 				continue;
 
-			if (COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json != NULL) {
-				document = COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json (
-					database,
-					json_object_get_object_member (obj, "doc"));
+			if (g_str_has_prefix (json_object_get_string_member (obj, "_id"),
+					      "_design/")) {
+				document = COUCHDB_DOCUMENT (couchdb_design_document_new ());
+				couchdb_document_set_from_json_object (document, obj);
 			} else {
-				document = couchdb_document_new_from_json_object (
-					json_object_get_object_member (obj, "doc"));
+				if (COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json != NULL) {
+					document = COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json (
+						database,
+						json_object_get_object_member (obj, "doc"));
+				} else {
+					document = couchdb_document_new_from_json_object (
+						json_object_get_object_member (obj, "doc"));
+				}
 			}
 			if (document != NULL)
 				doclist = g_slist_append (doclist, document);
diff --git a/couchdb-glib/couchdb-design-document.h b/couchdb-glib/couchdb-design-document.h
index cb9c6a9..642a0c1 100644
--- a/couchdb-glib/couchdb-design-document.h
+++ b/couchdb-glib/couchdb-design-document.h
@@ -41,7 +41,9 @@ typedef struct  {
 	CouchdbDocumentClass parent_class;
 } CouchdbDesignDocumentClass;
 
-GType                         couchdb_design_document_get_type (void);
+GType                  couchdb_design_document_get_type (void);
+
+CouchdbDesignDocument *couchdb_design_document_new (void);
 
 typedef enum {
 	COUCHDB_DESIGN_DOCUMENT_LANGUAGE_UNKNOWN,



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