import { Model } from "mongoose"; import { MongooseModule, } from "../helpers"; import { AudioStreamAuthenticationType } from "../types/audio-stream-authentication"; import { EncryptedDataType } from "../types/common"; export interface AudioStreamAuthentication extends AudioStreamAuthenticationType { } export default async function AudioStreamAuthenticationModule(mongoose: MongooseModule) { const { Schema } = mongoose; const EncryptedData = new Schema({ iv: { type: String, default: "", }, encryptedData: { type: String, default: "", }, }, { _id: false, id: false, }); const modelSchema = new Schema({ _id: { type: Schema.Types.ObjectId, auto: true, }, secret: { type: EncryptedData, default: null, }, rotateInterval: { type: Number, default: 0, required: true, }, name: { type: String, default: "", required: true, }, }, { autoIndex: false, toJSON: { versionKey: false, } }); modelSchema.index({ name: 1, }, { name: "name_1_unique", unique: true, }); return mongoose.model("AudioStreamAuthentication", modelSchema, "massive_audio_stream_authentication", { overwriteModels: true }); } export interface AudioStreamAuthenticationModel extends Model { }