All files / services/config-service/src/models StripeEvent.js

93.33% Statements 42/45
100% Branches 1/1
0% Functions 0/1
93.33% Lines 42/45

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 461x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x       1x 1x 1x  
const mongoose = require('mongoose');
 
const stripeEventSchema = new mongoose.Schema({
  stripeEventId: {
    type: String,
    required: true,
    unique: true
  },
  type: {
    type: String,
    required: true
  },
  data: {
    type: Object,
    default: {}
  },
  status: {
    type: String,
    enum: ['received', 'processed', 'failed'],
    default: 'received'
  },
  error: {
    type: String,
    default: null
  },
  organizationId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Organization',
    default: null
  },
  processedAt: {
    type: Date,
    default: null
  }
}, {
  timestamps: true
});
 
stripeEventSchema.methods.toJSON = function() {
  const obj = this.toObject();
  delete obj.__v;
  return obj;
};
 
module.exports = mongoose.model('StripeEvent', stripeEventSchema);