Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ptbrowne
Created May 12, 2017 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptbrowne/e84c15ccd0fe21a71315398474054699 to your computer and use it in GitHub Desktop.
Save ptbrowne/e84c15ccd0fe21a71315398474054699 to your computer and use it in GitHub Desktop.
queryAll for cozy client
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