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

replace all created to timestamps: true in db

Wentao Lyudd1f74da72ff
diff --git a/api/models/Conversation.js b/api/models/Conversation.js
index 1ff778e957..0ae336641c 100644
--- a/api/models/Conversation.js
+++ b/api/models/Conversation.js
@@ -38,11 +38,7 @@ const convoSchema = mongoose.Schema({
},
suggestions: [{ type: String }],
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
- created: {
- type: Date,
- default: Date.now
- }
-});
+}, { timestamps: true });
const Conversation =
mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);
@@ -85,14 +81,14 @@ module.exports = {
return { message: 'Error updating conversation' };
}
},
- // getConvos: async () => await Conversation.find({}).sort({ created: -1 }).exec(),
+ // getConvos: async () => await Conversation.find({}).sort({ createdAt: -1 }).exec(),
getConvos: async (pageNumber = 1, pageSize = 12) => {
try {
const skip = (pageNumber - 1) * pageSize;
// const limit = pageNumber * pageSize;
const conversations = await Conversation.find({})
- .sort({ created: -1 })
+ .sort({ createdAt: -1 })
.skip(skip)
// .limit(limit)
.limit(pageSize)
diff --git a/api/models/CustomGpt.js b/api/models/CustomGpt.js
index 33bb75b124..1f02bdc4db 100644
--- a/api/models/CustomGpt.js
+++ b/api/models/CustomGpt.js
@@ -12,11 +12,7 @@ const customGptSchema = mongoose.Schema({
type: String,
required: true
},
- created: {
- type: Date,
- default: Date.now
- }
-});
+}, { timestamps: true });
const CustomGpt = mongoose.models.CustomGpt || mongoose.model('CustomGpt', customGptSchema);
diff --git a/api/models/Message.js b/api/models/Message.js
index e6657c060a..b2017c2698 100644
--- a/api/models/Message.js
+++ b/api/models/Message.js
@@ -32,11 +32,12 @@ const messageSchema = mongoose.Schema({
type: String,
required: true
},
- created: {
- type: Date,
- default: Date.now
+ isCreatedByUser: {
+ type: Boolean,
+ required: true,
+ default: false
}
-});
+}, { timestamps: true });
const Message = mongoose.models.Message || mongoose.model('Message', messageSchema);
@@ -58,7 +59,7 @@ module.exports = {
},
getMessages: async (filter) => {
try {
- return await Message.find(filter).exec()
+ return await Message.find(filter).sort({createdAt: 1}).exec()
} catch (error) {
console.error(error);
return { message: 'Error getting messages' };
diff --git a/api/models/Prompt.js b/api/models/Prompt.js
index 612278d038..f122d5af40 100644
--- a/api/models/Prompt.js
+++ b/api/models/Prompt.js
@@ -12,11 +12,7 @@ const promptSchema = mongoose.Schema({
category: {
type: String,
},
- created: {
- type: Date,
- default: Date.now
- }
-});
+}, { timestamps: true });
const Prompt = mongoose.models.Prompt || mongoose.model('Prompt', promptSchema);