mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
* build/refactor: move lint/prettier packages to project root, install husky, add pre-commit hook * refactor: reformat files * build: put full eslintrc back with all rules
29 lines
876 B
JavaScript
29 lines
876 B
JavaScript
const Conversation = require('../models/schema/convoSchema');
|
|
const Preset = require('../models/schema/presetSchema');
|
|
|
|
const migrateConversations = async (userId) => {
|
|
try {
|
|
return await Conversation.updateMany({ user: null }, { $set: { user: userId } }).exec();
|
|
} catch (error) {
|
|
console.log(error);
|
|
return { message: 'Error saving conversation' };
|
|
}
|
|
};
|
|
|
|
const migratePresets = async (userId) => {
|
|
try {
|
|
return await Preset.updateMany({ user: null }, { $set: { user: userId } }).exec();
|
|
} catch (error) {
|
|
console.log(error);
|
|
return { message: 'Error saving conversation' };
|
|
}
|
|
};
|
|
|
|
const migrateDataToFirstUser = async (user) => {
|
|
const conversations = await migrateConversations(user.id);
|
|
console.log(conversations);
|
|
const presets = await migratePresets(user.id);
|
|
console.log(presets);
|
|
};
|
|
|
|
module.exports = migrateDataToFirstUser;
|