// connect-token.js
// Copyright (C) 2022 DTP Technologies, LLC
// License: Apache-2.0

'use strict';

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const ConnectTokenSchema = new Schema({
  created: { type: Date, default: Date.now, required: true, index: -1, expires: '1m' },
  userType: { type: String, enum: ['User', 'CoreUser'], required: true },
  user: { type: Schema.ObjectId, required: true, index: true, refPath: 'userType' },
  token: { type: String, required: true },
  claimed: { type: Date },
});

module.exports = mongoose.model('ConnectToken', ConnectTokenSchema);