diff --git a/models/schema/transaction.js b/models/schema/transaction.js index 95fd9fc86ab..50de7348055 100644 --- a/models/schema/transaction.js +++ b/models/schema/transaction.js @@ -1,34 +1,39 @@ const mongoose = require('mongoose'); -const transactionSchema = mongoose.Schema({ - user: { - type: mongoose.Schema.Types.ObjectId, - ref: 'User', - index: true, - required: true, +const transactionSchema = mongoose.Schema( + { + user: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + index: true, + required: true, + }, + conversationId: { + type: String, + ref: 'Conversation', + index: true, + }, + tokenType: { + type: String, + enum: ['prompt', 'completion', 'credits'], + required: true, + }, + model: { + type: String, + }, + context: { + type: String, + }, + valueKey: { + type: String, + }, + rate: Number, + rawAmount: Number, + tokenValue: Number, }, - conversationId: { - type: String, - ref: 'Conversation', - index: true, + { + timestamps: true, }, - tokenType: { - type: String, - enum: ['prompt', 'completion', 'credits'], - required: true, - }, - model: { - type: String, - }, - context: { - type: String, - }, - valueKey: { - type: String, - }, - rate: Number, - rawAmount: Number, - tokenValue: Number, -}); +); module.exports = transactionSchema;