import { Schema } from 'mongoose'

import { connectionAPI, connectionDefault } from '../config'

const ClientSchema = new Schema({
  clientID: {
    type: String, required: true, unique: true, index: true
  },
  clientDomain: {
    type: String, unqiue: true, index: true
  },
  name: {
    type: String, required: true
  },
  roles: [{type: String, required: true}],
  passwordAlgorithm: String,
  passwordHash: String,
  passwordSalt: String,
  certFingerprint: String,
  organization: String,
  location: String,
  softwareName: String,
  description: String,
  contactPerson: String,
  contactPersonEmail: String
})

// compile the Client Schema into a Model
export const ClientModelAPI = connectionAPI.model('Client', ClientSchema)
export const ClientModel = connectionDefault.model('Client', ClientSchema)

import { Schema } from 'mongoose'

import { connectionAPI, connectionDefault } from '../config'

const ClientSchema = new Schema({
  clientID: {
    type: String, required: true, unique: true, index: true
  },
  clientDomain: {
    type: String, index: true
  },
  name: {
    type: String, required: true
  },
  roles: [{type: String, required: true}],
  passwordAlgorithm: String,
  passwordHash: String,
  passwordSalt: String,
  certFingerprint: String,
  organization: String,
  location: String,
  softwareName: String,
  description: String,
  contactPerson: String,
  contactPersonEmail: String
})

// compile the Client Schema into a Model
export const ClientModelAPI = connectionAPI.model('Client', ClientSchema)
export const ClientModel = connectionDefault.model('Client', ClientSchema)

Remove misspelled field in Client Schema
Remove misspelled field in Client Schema

The client Domain field was intended to be unique, due to the misspelled
`unique` field this was not the case. The Client Domain field also does
not make sense to be unique as it's not required and multiple clients
could stem from one domain.

TRACE-126
