import { Schema, Document } from 'mongoose' import db from '../service/db' export interface IUApprelationModel extends Document { _id: string name: string applications?: any } const EnabledAppSchema = new Schema( { _creatorId: { type: Schema.Types.ObjectId, ref: 'User' }, _applicationId: { type: Schema.Types.ObjectId, ref: 'Application' }, order: { type: Number, default: 0 }, created: { type: Date, default: Date.now }, updated: { type: Date, default: Date.now } }, { _id: false, id: false, read: 'secondaryPreferred', toJSON: { versionKey: false, virtuals: true, getters: true } } ) const AppRelationSchema = new Schema( { _boundToObjectId: { type: Schema.Types.ObjectId, required: true }, boundToObjectType: { type: String, enum: ['project'], default: 'project' }, applications: [EnabledAppSchema], created: { type: Date, default: Date.now }, updated: { type: Date, default: Date.now } }, { id: false, toJSON: { versionKey: false, virtuals: true, getters: true } } ) export default db.model('Apprelation', AppRelationSchema)