Fix new document creation. Add collection name to DocumentPreview in search results

This commit is contained in:
Tom Moor
2017-07-14 22:15:56 -07:00
parent 2fea9fafd0
commit 2a9efaba8f
5 changed files with 15 additions and 4 deletions

View File

@ -193,12 +193,15 @@ router.post('documents.create', auth(), async ctx => {
text,
});
// reload to get all of the data needed to present (user, collection etc)
const document = await Document.findById(newDocument.id);
if (ownerCollection.type === 'atlas') {
await ownerCollection.addDocumentToStructure(newDocument, index);
await ownerCollection.addDocumentToStructure(document, index);
}
ctx.body = {
data: await presentDocument(ctx, newDocument),
data: await presentDocument(ctx, document),
};
});