DeletedSubscription.js 774 B

12345678910111213141516171819202122232425262728293031323334
  1. const mongoose = require('../infrastructure/Mongoose')
  2. const { SubscriptionSchema } = require('./Subscription')
  3. const { Schema } = mongoose
  4. const { ObjectId } = Schema
  5. const DeleterDataSchema = new Schema(
  6. {
  7. deleterId: { type: ObjectId, ref: 'User' },
  8. deleterIpAddress: { type: String },
  9. deletedAt: {
  10. type: Date,
  11. default() {
  12. return new Date()
  13. },
  14. },
  15. },
  16. { _id: false }
  17. )
  18. const DeletedSubscriptionSchema = new Schema(
  19. {
  20. deleterData: DeleterDataSchema,
  21. subscription: SubscriptionSchema,
  22. },
  23. { collection: 'deletedSubscriptions', minimize: false }
  24. )
  25. exports.DeletedSubscription = mongoose.model(
  26. 'DeletedSubscription',
  27. DeletedSubscriptionSchema
  28. )
  29. exports.DeletedSubscriptionSchema = DeletedSubscriptionSchema