diff --git a/server/maker.js b/server/maker.js index df14698..b198405 100644 --- a/server/maker.js +++ b/server/maker.js @@ -43,7 +43,8 @@ nano.db.destroy('keeper', function () { "views": { "taglist": { "map": function (doc) { if (doc.type == 1) { emit(null, doc); } } - } + }} + }, '_design/taglist', function (error, response) { console.log("_design/taglist added"); }); @@ -53,7 +54,8 @@ nano.db.destroy('keeper', function () { "views": { "getAllTags": { "map": function (doc) { if (doc.tags.list.length > 0) { emit(null, doc.tags.list); } } - } + }} + }, '_design/getAllTags', function (error, response) { console.log("_design/getAllTags added"); }); @@ -64,7 +66,8 @@ nano.db.destroy('keeper', function () { "getAllTags": { "map": function(doc) { if (doc.tags.list.length > 0) { for (var t=0;t< doc.tags.list.length;t++) { emit(doc._id, [doc.tags.list[t], doc.title]); } } } } - } + }} + }, '_design/getTagByKey', function (error, response) { console.log("_design/getTagByKey added"); }); diff --git a/server/viewinsert.js b/server/viewinsert.js new file mode 100644 index 0000000..94caf97 --- /dev/null +++ b/server/viewinsert.js @@ -0,0 +1,57 @@ +var nano = require('nano')('http://localhost:5984'); + +var db_name = 'keeper'; +var keeper = nano.use(db_name); + +keeper.insert( + { + "views": { + "taglist": { + "map": function (doc) { + if (doc.type == 1) { + emit(null, doc); + } + } + } + } + + }, '_design/taglist', function (error, response) { + console.log("_design/taglist added"); + }); + +keeper.insert( + { + "views": { + "getAllTags": { + "map": function (doc) { + if (doc.tags.list.length > 0) { + emit(null, doc.tags.list); + } + } + } + } + + }, '_design/getAllTags', function (error, response) { + console.log("_design/getAllTags added"); + }); + +keeper.insert( + { + "views": { + "getAllTags": { + "map": function (doc) { + if (doc.tags.list.length > 0) { + for (var t = 0; t < doc.tags.list.length; t++) { + emit(doc._id, [doc.tags.list[t], doc.title]); + } + } + } + } + } + + }, + '_design/getTagByKey', function (error, response) { + console.log("_design/getTagByKey added"); + } +) +; \ No newline at end of file