mirror of
https://github.com/donl/slouch.git
synced 2026-05-25 22:07:24 -06:00
* feat(getting-started) * feat(getting-started): destroy doc * doc(getting-started) * feat(examples)
32 lines
629 B
JavaScript
32 lines
629 B
JavaScript
'use strict';
|
|
|
|
var Slouch = require('../');
|
|
var slouch = new Slouch('http://admin:admin@localhost:5984');
|
|
|
|
// Create the database
|
|
slouch.db.create('mydb').then(function () {
|
|
|
|
// Create a doc
|
|
return slouch.doc.create('mydb', { _id: '1', foo: 'bar' });
|
|
|
|
}).then(function (doc) {
|
|
|
|
// Add the `yar` attr to the doc via a callback and ignore any conflicts
|
|
return slouch.doc.getModifyUpsert('mydb', '1', function (doc) {
|
|
|
|
doc.yar = (new Date()).getTime();
|
|
|
|
return doc;
|
|
|
|
});
|
|
|
|
}).then(function () {
|
|
|
|
// Destroy the database
|
|
return slouch.db.destroy('mydb');
|
|
|
|
}).then(function () {
|
|
|
|
// Database was destroyed
|
|
|
|
});
|