From 8f328ec6a3f6131223f993da74ea33f8989db49f Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Mon, 30 Oct 2023 09:41:07 -0400 Subject: [PATCH] feat(Tx): Add timestamps to transaction schema (#1123) --- api/models/schema/transaction.js | 61 +++++++++++++++++--------------- 1 file changed, 33 insertions(+), 28 deletions(-) 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;