All files / src/ram handlers.ts

83.33% Statements 5/6
0% Branches 0/1
100% Functions 1/1
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          8x   8x                         16x 16x       16x    
import { Model } from "@decaf-ts/decorator-validation";
import { Repo } from "../repository";
import { RelationsMetadata } from "../model";
import { RamFlags } from "./types";
import { Context } from "@decaf-ts/db-decorators";
import { UnsupportedError } from "../persistence";
 
export async function createdByOnRamCreateUpdate<
  M extends Model,
  R extends Repo<M, F, C>,
  V extends RelationsMetadata,
  F extends RamFlags,
  C extends Context<F>,
>(
  this: R,
  context: Context<F>,
  data: V,
  key: keyof M,
  model: M
): Promise<void> {
  const uuid: string = context.get("UUID");
  Iif (!uuid)
    throw new UnsupportedError(
      "This adapter does not support user identification"
    );
  model[key] = uuid as M[keyof M];
}