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

'use strict';

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const ChannelCredentialsSchema = new Schema({
  streamKey: { type: String, required: true },
  widgetKey: { type: String, required: true },
});

const VenueChannelSchema = new Schema({
  ownerType: { type: String, enum: ['CoreUser','User'], required: true },
  owner: { type: Schema.ObjectId, required: true, index: 1, refPath: 'ownerType' },
  slug: { type: String, lowercase: true, unique: true, index: 1 },
  name: { type: String, required: true, index: 1 },
  sortOrder: { type: Number, default: 0, required: true },
  credentials: { type: ChannelCredentialsSchema, required: true, select: false },
});

module.exports = mongoose.model('VenueChannel', VenueChannelSchema);