Created
October 15, 2014 20:56
-
-
Save jakobdamjensen/fa8517be4ba1043dd998 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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