diff --git a/src/db/models/authGrant.ts b/src/db/models/authGrant.ts index f932618a..92ed093b 100644 --- a/src/db/models/authGrant.ts +++ b/src/db/models/authGrant.ts @@ -39,7 +39,7 @@ const authGrantModel = (conn: Knex) => { // expose wrappers that require that a user is specified, // and transactionally create logs - const create = async ( + const create = ( data: UserData, actor: ParticipantId, date = new Date() @@ -61,10 +61,7 @@ const authGrantModel = (conn: Knex) => { }); }; - const update = async ( - data: UserData, - actor: ParticipantId - ): Promise => { + const update = (data: UserData, actor: ParticipantId): Promise => { return conn.transaction(async (trx) => { await authGrantLog.create( { diff --git a/src/db/models/form.ts b/src/db/models/form.ts index 04f14eb8..f2499cb1 100644 --- a/src/db/models/form.ts +++ b/src/db/models/form.ts @@ -47,12 +47,13 @@ export default defineVersionedModel({ }, }, }, - prepare: async (data) => ({ - belongsToType: data.belongsTo.type, - belongsToId: - data.belongsTo.type === 'operation' - ? data.belongsTo.operation - : undefined, - }), + prepare: (data) => + Promise.resolve({ + belongsToType: data.belongsTo.type, + belongsToId: + data.belongsTo.type === 'operation' + ? data.belongsTo.operation + : undefined, + }), }, }); diff --git a/src/db/models/operation.ts b/src/db/models/operation.ts index 5f22f76a..3e68eb85 100644 --- a/src/db/models/operation.ts +++ b/src/db/models/operation.ts @@ -47,6 +47,6 @@ export default defineVersionedModel({ data: OPERATION_DATA, lookupColumns: { columns: {}, - prepare: async () => ({}), + prepare: () => Promise.resolve({}), }, }); diff --git a/src/db/models/operationCluster.ts b/src/db/models/operationCluster.ts index 78804670..b5233bab 100644 --- a/src/db/models/operationCluster.ts +++ b/src/db/models/operationCluster.ts @@ -52,8 +52,9 @@ export default defineVersionedModel({ }, }, }, - prepare: async (data) => ({ - operationId: data.operation, - }), + prepare: (data) => + Promise.resolve({ + operationId: data.operation, + }), }, }); diff --git a/src/db/models/reportingWindow.ts b/src/db/models/reportingWindow.ts index c4a5562e..36dbba9a 100644 --- a/src/db/models/reportingWindow.ts +++ b/src/db/models/reportingWindow.ts @@ -59,12 +59,13 @@ export default defineVersionedModel({ }, }, }, - prepare: async (data) => ({ - belongsToType: data.belongsTo.type, - belongsToId: - data.belongsTo.type === 'operation' - ? data.belongsTo.operation - : undefined, - }), + prepare: (data) => + Promise.resolve({ + belongsToType: data.belongsTo.type, + belongsToId: + data.belongsTo.type === 'operation' + ? data.belongsTo.operation + : undefined, + }), }, }); diff --git a/src/db/util/id-model.ts b/src/db/util/id-model.ts index 867e90b0..4a783c69 100644 --- a/src/db/util/id-model.ts +++ b/src/db/util/id-model.ts @@ -76,7 +76,7 @@ export const defineIDModel = const model = defineSequelizeModel(opts)(conn); - const get = async (id: ID): Promise => + const get = (id: ID): Promise => model.findOne({ where: { [idField]: id, diff --git a/src/db/util/sequelize-model.ts b/src/db/util/sequelize-model.ts index ed598519..57c651a0 100644 --- a/src/db/util/sequelize-model.ts +++ b/src/db/util/sequelize-model.ts @@ -87,7 +87,7 @@ export const defineSequelizeModel = fields, })(conn); - const create: CreateFn = async (data, opts) => { + const create: CreateFn = (data, opts) => { return model.create( { ...data, @@ -98,7 +98,7 @@ export const defineSequelizeModel = ); }; - const update: UpdateFn = async (args) => { + const update: UpdateFn = (args) => { return model.update({ ...args, values: {