import { Schema, model } from 'mongoose'
import { paginate, toJSON } from '@/shared/utils/plugins/index.js'
import { IPropertyUsage, IPropertyUsageModel } from '../property.interfaces'

const propertyUsageSchema = new Schema<IPropertyUsage>(
  {
    name: { type: String, required: true, trim: true, unique:true},
    createdBy: { type: Schema.Types.ObjectId, ref: 'User' },
    updatedBy: { type: Schema.Types.ObjectId, ref: 'User' },
  },
  { timestamps: true },
)

propertyUsageSchema.plugin(toJSON)
propertyUsageSchema.plugin(paginate)

const PropertyUsage = model<IPropertyUsage, IPropertyUsageModel>('PropertyUsage', propertyUsageSchema)
export default PropertyUsage
