keeper/server/maker.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-03-02 13:53:28 +00:00
var nano = require('nano')('http://localhost:5984');
// clean up the database we created previously
2016-03-21 16:23:19 +00:00
nano.db.destroy('keeper', function () {
// create a new database
nano.db.create('keeper', function () {
// specify the database we are going to use
var keeper = nano.use('keeper');
// and insert a document in it
/* keeper.insert({ crazy: true }, 'rabbit', function(err, body, header) {
if (err) {
console.log('[alice.insert] ', err.message);
return;
}
console.log('you have inserted the rabbit.')
console.log(body);
});*/
keeper.insert(
{
"views": {
"titles": {
"map": function (doc) { emit(null, doc.title); }
}
}
}, '_design/titles', function (error, response) {
console.log("_design/titles added");
});
keeper.insert(
{
"views": {
"reducedView": {
"map": function (doc) { emit(null, [doc.title, doc.reduced]); }
}
}
}, '_design/reducedView', function (error, response) {
console.log("_design/reducedView added");
});
2016-03-21 16:27:14 +00:00
2016-03-21 16:23:19 +00:00
});
});
/**
2016-03-02 13:53:28 +00:00
* Created by Martin on 02/03/2016.
*/
2016-03-21 16:23:19 +00:00
2016-04-13 13:37:14 +00:00
/*
2016-03-21 16:23:19 +00:00
2016-03-21 22:37:36 +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-04-13 13:37:14 +00:00
*/