Created
May 12, 2017 07:44
-
-
Save ptbrowne/e84c15ccd0fe21a71315398474054699 to your computer and use it in GitHub Desktop.
queryAll for cozy client
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
const queryAll = function (cozyClient, mangoIndex, options) { | |
return new Promise((resolve, reject) => { | |
const documents = [] | |
const fetch = function () { | |
return cozyClient.data.query(mangoIndex, options) | |
.then(onSuccess) | |
.catch(reject) | |
} | |
const onSuccess = function (docs, response) { | |
debugger | |
if (response.next) { | |
documents.push.apply(documents, doc) | |
fetch() | |
} else { | |
resolve(documents) | |
} | |
} | |
fetch() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment