This commit is contained in:
Tom Moor
2017-07-06 20:59:45 -07:00
parent f90d170497
commit f08ca8d460
4 changed files with 18 additions and 17 deletions

View File

@ -1,5 +1,5 @@
// @flow
import { Star, User, Document, View } from '../models';
import { User, Document, View } from '../models';
import presentUser from './user';
import presentCollection from './collection';
@ -19,7 +19,6 @@ async function present(ctx: Object, document: Document, options: Object = {}) {
text: document.text,
html: document.html,
preview: document.preview,
collection: presentCollection(ctx, document.collection),
createdAt: document.createdAt,
createdBy: presentUser(ctx, document.createdBy),
updatedAt: document.updatedAt,
@ -27,9 +26,14 @@ async function present(ctx: Object, document: Document, options: Object = {}) {
team: document.teamId,
collaborators: [],
starred: !!document.starred,
collection: undefined,
views: undefined,
};
if (options.includeCollection) {
data.collection = presentCollection(ctx, document.collection);
}
if (options.includeViews) {
data.views = await View.sum('count', {
where: { documentId: document.id },