2017-11-26 19:15:00 +02:00
|
|
|
import { createQuery, MemoryResultCacher } from 'meteor/cultofcoders:grapher';
|
2016-10-07 10:31:58 +03:00
|
|
|
import postListExposure from './queries/postListExposure.js';
|
|
|
|
|
2017-11-23 21:02:00 +02:00
|
|
|
const postList = createQuery('postList', {
|
2016-10-07 10:31:58 +03:00
|
|
|
posts: {
|
2017-11-26 20:18:30 +02:00
|
|
|
$filter({filters, options, params}) {
|
|
|
|
if (params.title) {
|
|
|
|
filters.title = params.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.limit) {
|
|
|
|
options.limit = params.limit;
|
|
|
|
}
|
2016-10-07 10:31:58 +03:00
|
|
|
},
|
|
|
|
title: 1,
|
|
|
|
author: {
|
|
|
|
name: 1
|
|
|
|
},
|
|
|
|
group: {
|
|
|
|
name: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-11-26 19:15:00 +02:00
|
|
|
|
2016-10-07 10:31:58 +03:00
|
|
|
export { postList };
|
|
|
|
export { postListExposure };
|
|
|
|
|
|
|
|
postListExposure.expose({
|
|
|
|
firewall(userId, params) {
|
|
|
|
},
|
|
|
|
embody: {
|
|
|
|
$filter({filters, params}) {
|
|
|
|
filters.title = params.title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-11-26 19:15:00 +02:00
|
|
|
|
|
|
|
const postListCached = createQuery('postListCached', {
|
|
|
|
posts: {
|
|
|
|
title: 1,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export {postListCached};
|
|
|
|
|
|
|
|
postListCached.cacheResults(new MemoryResultCacher({
|
2017-11-26 23:52:37 +02:00
|
|
|
ttl: 200,
|
2017-11-26 19:15:00 +02:00
|
|
|
}));
|