mirror of
https://github.com/vale981/grapher
synced 2025-03-10 12:56:41 -04:00
35 lines
No EOL
794 B
JavaScript
35 lines
No EOL
794 B
JavaScript
import Posts from './collection.js';
|
|
import Authors from '../authors/collection.js';
|
|
import Comments from '../comments/collection.js';
|
|
import Tags from '../tags/collection.js';
|
|
import Groups from '../groups/collection.js';
|
|
|
|
Posts.addLinks({
|
|
author: {
|
|
type: 'one',
|
|
collection: Authors,
|
|
field: 'ownerId',
|
|
index: true
|
|
},
|
|
comments: {
|
|
collection: Comments,
|
|
inversedBy: 'post'
|
|
},
|
|
tags: {
|
|
collection: Tags,
|
|
type: 'many',
|
|
field: 'tagIds',
|
|
index: true
|
|
},
|
|
commentsCount: {
|
|
resolve(post) {
|
|
return Comments.find({postId: post._id}).count();
|
|
}
|
|
},
|
|
group: {
|
|
type: 'one',
|
|
collection: Groups,
|
|
metadata: true,
|
|
field: 'groupId'
|
|
}
|
|
}); |