You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,22 +18,28 @@ var PouchDB = require('pouchdb');
18
18
var seed =require('pouchdb-seed-design');
19
19
var db =newPouchDB('http://localhost:5984/design');
20
20
21
-
seed(db, {
22
-
person: {
23
-
views: {
24
-
byFirstName:function (doc) {
25
-
emit(doc.firstName);
26
-
},
27
-
byLastName:function (doc) {
28
-
emit(doc.lastName);
29
-
},
30
-
byFullName:function (doc) {
31
-
emit(doc.firstName+''+doc.lastName);
32
-
}
33
-
}
21
+
var ddoc = {
22
+
person: {
23
+
views: {
24
+
byFirstName:function (doc) {
25
+
emit(doc.firstName);
26
+
},
27
+
byLastName:function (doc) {
28
+
emit(doc.lastName);
29
+
},
30
+
byFullName:function (doc) {
31
+
emit(doc.firstName+''+doc.lastName);
32
+
}
33
+
}
34
+
}
35
+
};
36
+
37
+
var promise =seed(db, ddoc).then(function(updated) {
38
+
if(updated) {
39
+
console.log('DDocs updated!');
40
+
} else {
41
+
console.log('No update was necessary');
34
42
}
35
-
}, function () {
36
-
console.dir(arguments);
37
43
});
38
44
```
39
45
@@ -49,21 +55,15 @@ Creates a set of CouchDB design documents basing on `design` object. Each key in
49
55
50
56
If no changes between remote design documents and `design` object are detected, no updates are sent to CouchDB.
51
57
52
-
In addition to invoking the optional callback, seed also returns a [Bluebird Promise](https://github.com/petkaantonov/bluebird/blob/master/API.md).
53
-
54
-
```js
55
-
seed(db, design)
56
-
.then(function(results) {
57
-
console.log(results);
58
-
}, function(err){
59
-
console.log(err);
60
-
});
61
-
```
58
+
Seed will return a Promise that fulfills with `false` if no updates were necessary, or the result of the `bulkDocs` operation if changes were pushed. (You will need a `Promise` shim if you are using an older browser or version of Node.)
62
59
63
60
## Updates
64
61
62
+
##### (0.3.0) 2016-05-08
63
+
You can now use docs with absolutely any JSON schema. All functions in the tree are converted to strings. This will future proof `pouchdb-seed-design` as the design doc standards evolve. Added browser support.
64
+
65
65
##### (0.2.0) 2015-09-16
66
-
Added support for `filters`, `lists`, `shows`, and `validate_doc_update` thanks to [Will Holley](https://github.com/colinskow/pouchdb-seed-design/pull/2). Updated to PouchDB `4.0.X`. Removed Bluebird Promise dependency, preferring native and using [lie](https://github.com/calvinmetcalf/lie) as a fallback.
66
+
Added support for `filters`, `lists`, `shows`, and `validate_doc_update` thanks to [Will Holley](https://github.com/colinskow/pouchdb-seed-design/pull/2).
0 commit comments