From 5d180e60245fa8a3b6d1846fa3fb4f71a760a94b Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 20 May 2013 17:46:49 -0400 Subject: [PATCH] add copy of current couchdb design docs --- resources/couchdb/design docs/posts.js | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resources/couchdb/design docs/posts.js diff --git a/resources/couchdb/design docs/posts.js b/resources/couchdb/design docs/posts.js new file mode 100644 index 0000000..29a30e0 --- /dev/null +++ b/resources/couchdb/design docs/posts.js @@ -0,0 +1,27 @@ +{ + "_id": "_design/posts", + "language": "javascript", + "views": { + "listTags": { + "map": "function(doc) {\n if (doc.type === \"post\") {\n for (var i in doc.tags) {\n emit(doc.tags[i], null);\n }\n }\n}", + "reduce": "function(keys, values) {\n return null;\n}" + }, + "listPosts": { + "map": "function(doc) {\n if (doc.type === \"post\") {\n emit([doc.created_at, doc.slug], doc)\n }\n}" + }, + "listPostsBySlug": { + "map": "function(doc) {\n if (doc.type === \"post\") {\n var date = new Date(doc.created_at)\n var dateStr = date.getFullYear() + \"-\" + (date.getMonth() + 1) + \"-\" + date.getDate()\n emit([dateStr, doc.slug], doc)\n }\n}" + }, + "listPublishedPosts": { + "map": "function(doc) {\n if (doc.type === \"post\" && doc.published === true) {\n emit([doc.created_at, doc.slug], doc)\n }\n}" + }, + "countPublishedPosts": { + "map": "function(doc) {\n if (doc.type === \"post\" && doc.published === true) {\n emit(\"published post\", 1)\n }\n}", + "reduce": "function(keys, values) {\n return sum(values);\n}" + }, + "countPosts": { + "map": "function(doc) {\n if (doc.type === \"post\") {\n emit(\"any post\", 1)\n }\n}", + "reduce": "function(keys, values) {\n return sum(values);\n}" + } + } +} \ No newline at end of file