link.ts 965 B

1234567891011121314151617181920212223242526272829303132
  1. import { Document, model, Schema, Types } from 'mongoose';
  2. import { IDomain } from './domain';
  3. export interface ILink extends Document {
  4. banned?: boolean;
  5. bannedBy?: Types.ObjectId;
  6. count?: number;
  7. createdAt?: Date;
  8. domain?: Types.ObjectId | IDomain;
  9. id: string;
  10. password?: string;
  11. target: string;
  12. updatedAt?: Date;
  13. user?: Types.ObjectId;
  14. }
  15. const LinkSchema: Schema = new Schema({
  16. banned: { type: Boolean, default: false },
  17. bannedBy: { type: Schema.Types.ObjectId, ref: 'user' },
  18. count: { type: Number, default: 0 },
  19. createdAt: { type: Date, default: Date.now },
  20. domain: { type: Schema.Types.ObjectId, ref: 'domain' },
  21. id: { type: String, required: true, trim: true },
  22. password: { type: String, trim: true },
  23. target: { type: String, required: true },
  24. updatedAt: { type: Date, default: Date.now },
  25. user: { type: Schema.Types.ObjectId, ref: 'user' },
  26. });
  27. const Link = model<ILink>('link', LinkSchema);
  28. export default Link;