Open DevTools to see the results after hitting the Run button
xenia()
.collection('users')
.sample(10)
.exec()
.then(function(res){
console.log(res.results)
})
xenia()
.include(['name', 'avatar',
'statistics.comments.all.all',
'stats'])
.sort(['stats.comments', -1])
.limit(10)
.exec()
.then(function(res){
console.log(res.results)
})
xenia()
.project({
count: {
$subtract: ['$stats.comments', {
/* 50 is the interval size.
A higher number means
less datapoints */
$mod: ['$stats.comments', 50]
}]
}, _id: false })
.group({ _id: '$count', count: { $sum: 1 } })
.sort(['_id', 1])
.exec()
.then(function(res){
console.log(res.results[0].Docs)
})
var flagged = 'statistics.comments'
flagged += '.all.ratios.SystemFlagged'
xenia()
.include(['name', 'avatar', flagged])
.sort([flagged, -1])
.limit(20)
.exec()
.then(function(res) {
console.log(res.results[0].Docs)
})
xenia()
.collection('comments')
.include(['body', 'date_created', 'status'])
.match({ status: 'Untouched' })
.sort(['date_created', 1])
.limit(20)
.exec()
.then(function(res) {
console.log(res.results[0].Docs)
})
xenia()
.collection('comments')
.sample(20)
.join('assets', '_id', 'asset_id', 'article')
.exec()
.then(function(res) {
console.log(res.results[0].Docs)
})
function getComments(page, pageSize) {
return xenia()
.collection('comments')
.limit(pageSize)
// page count starts in 1
.skip(pageSize * (page - 1))
.exec()
}
getComments(3, 15)
.then(function(res) {
console.log(res.results[0].Docs)
});