createDataset.ts
677 Bytes
import * as R from "ramda";
import { Context } from "../";
import Contract from "entity/Contract";
import Drone from "entity/Drone";
import Dataset from "entity/Dataset";
import User from "entity/User";
import Org from "entity/Org";
export default async (
root: {},
{ input: { comment, droneId } },
context: Context
) => {
const { connection } = context;
const datasetRepo = connection.getRepository(Dataset);
const droneRepo = connection.getRepository(Drone);
const drone = await droneRepo.findOneById(droneId);
let dataset = new Dataset();
dataset.comment = comment;
dataset.producer = drone!;
await datasetRepo.save(dataset);
return dataset;
};