cloud-ide-model-schema
Version:
Pachage for schema management of Cloud IDEsys LMS
80 lines (79 loc) • 2.03 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CSubscriptionPayment = void 0;
var mongoose_1 = require("mongoose");
var subscription_payments = new mongoose_1.Schema({
spay_subscription_id: {
type: mongoose_1.default.Schema.Types.ObjectId,
ref: "subscriptions",
required: true
},
spay_amount: {
type: Number,
required: true,
min: 0
},
spay_currency: {
type: String,
required: true,
maxlength: 3,
default: 'USD',
uppercase: true
},
spay_payment_method: {
type: String,
required: true,
maxlength: 50
},
spay_transaction_id: {
type: String,
maxlength: 200
},
spay_payment_gateway: {
type: String,
maxlength: 100
},
spay_status: {
type: String,
required: true,
enum: ['pending', 'completed', 'failed', 'refunded'],
default: 'pending'
},
spay_billing_period_start: {
type: Date,
required: true
},
spay_billing_period_end: {
type: Date,
required: true
},
spay_paid_at: {
type: Date
},
spay_failure_reason: {
type: String,
maxlength: 500
},
spay_invoice_url: {
type: String,
maxlength: 500
},
spay_receipt_url: {
type: String,
maxlength: 500
},
spay_created_at: {
type: Date,
default: Date.now
},
spay_isactive: {
type: Boolean,
default: true
}
}, { collection: 'subscription_payments', timestamps: { createdAt: 'spay_created_at' } });
// Indexes
subscription_payments.index({ spay_subscription_id: 1, spay_created_at: -1 });
subscription_payments.index({ spay_status: 1 });
subscription_payments.index({ spay_transaction_id: 1 });
var CSubscriptionPayment = mongoose_1.default.model("subscription_payments", subscription_payments);
exports.CSubscriptionPayment = CSubscriptionPayment;