chore: Remove over-usage of invariant (#3719)

This commit is contained in:
Tom Moor
2022-07-02 15:29:39 +03:00
committed by GitHub
parent 108b5b934a
commit c9cd424a8d
16 changed files with 34 additions and 55 deletions

View File

@@ -1,4 +1,3 @@
import invariant from "invariant";
import { Transaction } from "sequelize";
import { Document, Event, User } from "@server/models";
@@ -105,14 +104,12 @@ export default async function documentCreator({
// reload to get all of the data needed to present (user, collection etc)
// we need to specify publishedAt to bypass default scope that only returns
// published documents
const doc = await Document.findOne({
return await Document.findOne({
where: {
id: document.id,
publishedAt: document.publishedAt,
},
rejectOnEmpty: true,
transaction,
});
invariant(doc, "Document must exist");
return doc;
}