Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

feat(Tx): Add timestamps to transaction schema (#1123)

Danny Avila8f328ec6a3f6
diff --git a/api/models/schema/transaction.js b/api/models/schema/transaction.js
index 95fd9fc86a..50de734805 100644
--- a/api/models/schema/transaction.js
+++ b/api/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;