working sydney, need to test the other models

This commit is contained in:
Daniel Avila 2023-03-08 22:30:29 -05:00
parent 2c1ae68dc4
commit 67054e7504
6 changed files with 75 additions and 26 deletions

View file

@ -47,6 +47,15 @@ const convoSchema = mongoose.Schema({
const Conversation =
mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);
const getConvo = async (conversationId) => {
try {
return await Conversation.findOne({ conversationId }).exec();
} catch (error) {
console.log(error);
return { message: 'Error getting single conversation' };
}
};
module.exports = {
saveConvo: async ({ conversationId, title, ...convo }) => {
try {
@ -95,12 +104,14 @@ module.exports = {
return { message: 'Error getting conversations' };
}
},
getConvo: async (conversationId) => {
getConvo,
getConvoTitle: async (conversationId) => {
try {
return await Conversation.findOne({ conversationId }).exec();
const convo = await getConvo(conversationId);
return convo.title;
} catch (error) {
console.log(error);
return { message: 'Error getting single conversation' };
return { message: 'Error getting conversation title' };
}
},
deleteConvos: async (filter) => {