Skip to content

Instantly share code, notes, and snippets.

@jakobdamjensen
Created October 15, 2014 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jakobdamjensen/fa8517be4ba1043dd998 to your computer and use it in GitHub Desktop.
Save jakobdamjensen/fa8517be4ba1043dd998 to your computer and use it in GitHub Desktop.
new Region()
.publishedDocuments()
.query({whereIn: ['regions.id', regionIds], where: ['publishedDocuments.updated_at', '>=', new Date(timestamp)]})
.fetchAll({withRelated: [
'publishedDocuments.images',
'publishedDocuments.ecareSections',
'publishedDocuments.regions']
})
.then(function (collection) {
var map = {}, keys, i, maxLength, result = [];
collection.forEach(function (region) {
region.relations.publishedDocuments.forEach(function (document) {
if (map[document.id] === undefined) {
map[document.id] = document;
result.push(document);
}
});
});
res.json({
total_documents: result.length,
documents: result
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment