forked from 1313-Mockingbird-Lane/data-objects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpouchdb-test.html
More file actions
53 lines (45 loc) · 1.38 KB
/
pouchdb-test.html
File metadata and controls
53 lines (45 loc) · 1.38 KB
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
45
46
47
48
49
50
51
52
53
<!-- <!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://cdn.jsdelivr.net/pouchdb/6.2.0/pouchdb.min.js"></script>
</head>
<body>
<script type="text/javascript">
class Member {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.zipcode = '19806';
this._id = this.firstName + ' ' + this.lastName;
}
static fromJson(json) {
var data = JSON.parse(json);
return new Member(data.firstName, data.lastName);
}
static fromArray(array) {
return new Member(...array);
}
toJson() {
return JSON.stringify(this);
}
}
var tom = Member.fromJson('{"firstName":"Tom","lastName":"Marks"}')
var db = new PouchDB('members');
db.put(tom);
db.get('Tom Marks').then(function (doc) {
console.log(doc);
});
db.query(function (doc, emit) {
emit(doc.zipcode);
}, {key: '19806'}).then(function (result) {
// found docs with name === 'foo'
console.log(result);
window.tmp = result;
}).catch(function (err) {
// handle any errors
console.error(err);
});
</script>
</body>
</html> -->