-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from Terreii/pouchdb-hoodie-api
Add support for pouchdb-hoodie-api
- Loading branch information
Showing
27 changed files
with
1,669 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
module.exports = pull | ||
|
||
var Promise = require('lie') | ||
|
||
/** | ||
* Pull documents from a remote database. | ||
* @param {string[]} ids Document ids | ||
* @param {PouchDB.Database} db Local PouchDB database. | ||
* @param {string|PouchDB.Database} remote Remote PouchDB database, or its URL. | ||
*/ | ||
function pull (ids, db, remote) { | ||
return new Promise(function (resolve, reject) { | ||
var pulledObjects = [] | ||
|
||
var replication = db.replicate.from(remote, { | ||
doc_ids: ids | ||
}) | ||
|
||
replication.on('complete', function () { | ||
resolve(pulledObjects) | ||
}) | ||
|
||
replication.on('error', reject) | ||
|
||
replication.on('change', function (change) { | ||
pulledObjects = pulledObjects.concat(change.docs) | ||
}) | ||
}) | ||
} |
Oops, something went wrong.