judgeContract.ts 568 Bytes
import * as R from "ramda";
import { Context } from "../";
import Contract from "entity/Contract";
import Drone from "entity/Drone";
import User from "entity/User";
import Org from "entity/Org";

export default async (root: {}, { id, ok, review }, context: Context) => {
  const { connection } = context;
  const contractRepo = connection.getRepository(Contract);

  const result = await contractRepo
    .createQueryBuilder()
    .update(Contract)
    .set({ status: ok ? "ok" : "rejected", review })
    .where("id = :id", { id })
    .execute();

  return null;
};