mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
replace all created to timestamps: true in db
This commit is contained in:
parent
5d65427a6e
commit
dd1f74da72
4 changed files with 11 additions and 22 deletions
|
|
@ -38,11 +38,7 @@ const convoSchema = mongoose.Schema({
|
||||||
},
|
},
|
||||||
suggestions: [{ type: String }],
|
suggestions: [{ type: String }],
|
||||||
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
|
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
|
||||||
created: {
|
}, { timestamps: true });
|
||||||
type: Date,
|
|
||||||
default: Date.now
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const Conversation =
|
const Conversation =
|
||||||
mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);
|
mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);
|
||||||
|
|
@ -85,14 +81,14 @@ module.exports = {
|
||||||
return { message: 'Error updating conversation' };
|
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) => {
|
getConvos: async (pageNumber = 1, pageSize = 12) => {
|
||||||
try {
|
try {
|
||||||
const skip = (pageNumber - 1) * pageSize;
|
const skip = (pageNumber - 1) * pageSize;
|
||||||
// const limit = pageNumber * pageSize;
|
// const limit = pageNumber * pageSize;
|
||||||
|
|
||||||
const conversations = await Conversation.find({})
|
const conversations = await Conversation.find({})
|
||||||
.sort({ created: -1 })
|
.sort({ createdAt: -1 })
|
||||||
.skip(skip)
|
.skip(skip)
|
||||||
// .limit(limit)
|
// .limit(limit)
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,7 @@ const customGptSchema = mongoose.Schema({
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
created: {
|
}, { timestamps: true });
|
||||||
type: Date,
|
|
||||||
default: Date.now
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const CustomGpt = mongoose.models.CustomGpt || mongoose.model('CustomGpt', customGptSchema);
|
const CustomGpt = mongoose.models.CustomGpt || mongoose.model('CustomGpt', customGptSchema);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,12 @@ const messageSchema = mongoose.Schema({
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
created: {
|
isCreatedByUser: {
|
||||||
type: Date,
|
type: Boolean,
|
||||||
default: Date.now
|
required: true,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
});
|
}, { timestamps: true });
|
||||||
|
|
||||||
const Message = mongoose.models.Message || mongoose.model('Message', messageSchema);
|
const Message = mongoose.models.Message || mongoose.model('Message', messageSchema);
|
||||||
|
|
||||||
|
|
@ -58,7 +59,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
getMessages: async (filter) => {
|
getMessages: async (filter) => {
|
||||||
try {
|
try {
|
||||||
return await Message.find(filter).exec()
|
return await Message.find(filter).sort({createdAt: 1}).exec()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return { message: 'Error getting messages' };
|
return { message: 'Error getting messages' };
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,7 @@ const promptSchema = mongoose.Schema({
|
||||||
category: {
|
category: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
created: {
|
}, { timestamps: true });
|
||||||
type: Date,
|
|
||||||
default: Date.now
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const Prompt = mongoose.models.Prompt || mongoose.model('Prompt', promptSchema);
|
const Prompt = mongoose.models.Prompt || mongoose.model('Prompt', promptSchema);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue