-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.js
44 lines (37 loc) · 858 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const PouchDB = require('pouchdb');
PouchDB.plugin(require('./pouchdb-s3leveldown'));
if (!process.env.S3_TEST_BUCKET) {
console.error("Please set the S3_TEST_BUCKET environment variable to run the test");
process.exit(1);
return;
}
const db = new PouchDB(process.env.S3_TEST_BUCKET, { adapter: 's3leveldown' });
function addTodo(text) {
const todo = {
_id: `todo:${text}`,
title: text,
completed: false
};
db.put(todo, (err, result) => {
if (!err) {
console.log('Successfully posted a todo!');
}
else {
console.log(err);
}
});
}
function showTodos() {
db.allDocs({include_docs: true, descending: true}, (err, doc) => {
if (!err) {
console.log(doc.rows);
}
else {
console.log(err);
}
});
}
addTodo('shopping');
addTodo('isolate');
addTodo('exercise');
showTodos();