bcgov/common-object-management-service

View on GitHub
app/src/db/models/tables/invite.js

Summary

Maintainability
A
0 mins
Test Coverage
F
57%
const { Model } = require('objection');

const { stamps } = require('../jsonSchema');
const { Timestamps } = require('../mixins');

class ObjectModel extends Timestamps(Model) {
  static get tableName() {
    return 'invite';
  }

  static get idColumn() {
    return 'token';
  }

  static get jsonSchema() {
    return {
      type: 'object',
      required: ['token', 'resource', 'type'],
      properties: {
        token: { type: 'string', format: 'uuid' },
        email: { type: 'string', format: 'email', nullable: true },
        resource: { type: 'string', format: 'uuid' },
        type: { type: 'string', enum: ['bucketId', 'objectId'] },
        expiresAt: { type: 'string', format: 'date-time' },
        permCodes: { type: 'array', items: { type: 'string' } },
        ...stamps
      },
      additionalProperties: false
    };
  }
}

module.exports = ObjectModel;