Skip to content

Commit

Permalink
Define participant DB model
Browse files Browse the repository at this point in the history
  • Loading branch information
Pl217 committed Sep 6, 2021
1 parent ebab717 commit 1dcbb24
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Knex = require('knex');
import attachmentVersion from './models/attachmentVersion';
import attachment from './models/attachment';
import attachmentVersion from './models/attachmentVersion';
import authGrant from './models/authGrant';
import authGrantee from './models/authGrantee';
import authGrantLog from './models/authGrantLog';
Expand All @@ -10,6 +10,7 @@ import form from './models/form';
import governingEntity from './models/governingEntity';
import operation from './models/operation';
import operationCluster from './models/operationCluster';
import participant from './models/participant';
import reportingWindow from './models/reportingWindow';
import reportingWindowAssignment from './models/reportingWindowAssignment';

Expand All @@ -25,6 +26,7 @@ export default (conn: Knex) => ({
governingEntity: governingEntity(conn),
operation: operation(conn),
operationCluster: operationCluster(conn),
participant: participant(conn),
reportingWindow: reportingWindow(conn),
reportingWindowAssignment: reportingWindowAssignment(conn),
});
20 changes: 20 additions & 0 deletions src/db/models/participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as t from 'io-ts';

import { brandedType } from '../../util/io-ts';
import { Brand } from '../../util/types';
import { defineIDModel } from '../util/id-model';

export type ParticipantId = Brand<
number,
Expand All @@ -10,3 +11,22 @@ export type ParticipantId = Brand<
>;

export const PARTICIPANT_ID = brandedType<number, ParticipantId>(t.number);

export default defineIDModel({
tableName: 'participant',
fields: {
generated: {
id: { kind: 'branded-integer', brand: PARTICIPANT_ID },
},
optional: {
hidId: { kind: 'checked', type: t.string },
hidSub: { kind: 'checked', type: t.string },
email: { kind: 'checked', type: t.string },
name_given: { kind: 'checked', type: t.string },
name_family: { kind: 'checked', type: t.string },
},
required: {},
},
idField: 'id',
softDeletionEnabled: false,
});

0 comments on commit 1dcbb24

Please sign in to comment.