host.ts 676 B

1234567891011121314151617181920212223
  1. import { Document, model, Schema, Types } from 'mongoose';
  2. export interface IHost extends Document {
  3. address: string;
  4. banned?: boolean;
  5. bannedBy?: Types.ObjectId;
  6. createdAt?: Date;
  7. updatedAt?: Date;
  8. user?: Types.ObjectId;
  9. }
  10. const HostSchema: Schema = new Schema({
  11. address: { type: String, unique: true, trim: true, required: true },
  12. banned: { type: Boolean, default: false },
  13. bannedBy: { type: Schema.Types.ObjectId, ref: 'user' },
  14. createdAt: { type: Date, default: Date.now },
  15. updatedAt: { type: Date, default: Date.now },
  16. user: { type: Schema.Types.ObjectId, ref: 'user' },
  17. });
  18. const Host = model<IHost>('host', HostSchema);
  19. export default Host;