keeper/server/viewinsert.js

144 lines
3.1 KiB
JavaScript
Raw Normal View History

2016-03-21 16:27:14 +00:00
var nano = require('nano')('http://localhost:5984');
var db_name = 'keeper';
var keeper = nano.use(db_name);
2016-03-21 16:47:47 +00:00
keeper.destroy('_design/titles', function(err, body) {
2016-03-21 16:50:23 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:57:17 +00:00
console.log('titles deleted');
keeper.insert(
{
"views": {
"titles": {
"map": function (doc) { emit(null, doc.title); }
}
}
}, '_design/titles', function (error, response) {
if (error) {
console.log(error);
} else
{
2016-03-21 17:03:40 +00:00
console.log('remade : ' + _design/titles);
2016-03-21 16:57:17 +00:00
console.log(response);
}
});
2016-03-21 16:50:23 +00:00
}
2016-03-21 16:47:08 +00:00
});
2016-03-21 16:57:17 +00:00
/*
2016-03-21 16:47:47 +00:00
keeper.destroy('_design/reducedView', function(err, body) {
2016-03-21 16:50:23 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:53:26 +00:00
console.log('deleted');
2016-03-21 16:47:08 +00:00
console.log(body);
2016-03-21 16:50:23 +00:00
}
2016-03-21 16:47:08 +00:00
});
2016-03-21 16:47:47 +00:00
keeper.destroy('_design/taglist', function(err, body) {
2016-03-21 16:50:23 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:53:26 +00:00
console.log('deleted');
2016-03-21 16:47:08 +00:00
console.log(body);
2016-03-21 16:50:23 +00:00
}
2016-03-21 16:47:08 +00:00
});
2016-03-21 16:47:47 +00:00
keeper.destroy('_design/getAllTags', function(err, body) {
2016-03-21 16:50:23 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:53:26 +00:00
console.log('deleted');
2016-03-21 16:47:08 +00:00
console.log(body);
2016-03-21 16:50:23 +00:00
}
2016-03-21 16:47:08 +00:00
});
2016-03-21 16:47:47 +00:00
keeper.destroy('_design/getTagByKey', function(err, body) {
2016-03-21 16:50:23 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:53:26 +00:00
console.log('deleted');
2016-03-21 16:47:08 +00:00
console.log(body);
2016-03-21 16:50:23 +00:00
}
2016-03-21 16:47:08 +00:00
});
2016-03-21 16:57:17 +00:00
2016-03-21 16:47:08 +00:00
keeper.insert(
{
"views": {
"reducedView": {
"map": function (doc) { emit(null, [doc.title, doc.reduced]); }
}
}
}, '_design/reducedView', function (error, response) {
2016-03-21 16:51:50 +00:00
if (error) {
console.log(error);
} else
{
console.log(response);
}
2016-03-21 16:47:08 +00:00
});
2016-03-21 16:27:14 +00:00
keeper.insert(
{
"views": {
"taglist": {
2016-03-21 16:40:15 +00:00
"map": function (doc) { if (doc.type == 1) { emit(null, doc); } }
2016-03-21 16:27:14 +00:00
}
}
}, '_design/taglist', function (error, response) {
2016-03-21 16:40:15 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:51:50 +00:00
console.log(response);
2016-03-21 16:40:15 +00:00
}
2016-03-21 16:27:14 +00:00
});
keeper.insert(
{
"views": {
"getAllTags": {
2016-03-21 16:40:15 +00:00
"map": function (doc) { if (doc.tags.list.length > 0) { emit(null, doc.tags.list); } }
2016-03-21 16:27:14 +00:00
}
}
}, '_design/getAllTags', function (error, response) {
2016-03-21 16:40:15 +00:00
if (error) {
console.log(error);
} else
{
2016-03-21 16:51:50 +00:00
console.log(response);
2016-03-21 16:40:15 +00:00
}
2016-03-21 16:27:14 +00:00
});
2016-03-21 16:40:15 +00:00
2016-03-21 16:27:14 +00:00
keeper.insert(
{
"views": {
2016-03-21 16:40:15 +00:00
"getTagByKey": {
"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]); } } }
2016-03-21 16:27:14 +00:00
}
}
2016-03-21 16:40:15 +00:00
}, '_design/getTagByKey', function (error, response) {
if (error) {
console.log(error);
} else
{
2016-03-21 16:51:50 +00:00
console.log(response);
2016-03-21 16:40:15 +00:00
}
2016-03-21 16:27:14 +00:00
2016-03-21 16:57:17 +00:00
});*/