diff --git a/api/models/Action.js b/api/models/Action.js index 7971f3e61a..299b3bf20a 100644 --- a/api/models/Action.js +++ b/api/models/Action.js @@ -5,17 +5,16 @@ const Action = mongoose.model('action', actionSchema); /** * Update an action with new data without overwriting existing properties, - * or create a new action if it doesn't exist, within a transaction session if provided. + * or create a new action if it doesn't exist. * * @param {Object} searchParams - The search parameters to find the action to update. * @param {string} searchParams.action_id - The ID of the action to update. * @param {string} searchParams.user - The user ID of the action's author. * @param {Object} updateData - An object containing the properties to update. - * @param {mongoose.ClientSession} [session] - The transaction session to use. * @returns {Promise} The updated or newly created action document as a plain object. */ -const updateAction = async (searchParams, updateData, session = null) => { - const options = { new: true, upsert: true, session }; +const updateAction = async (searchParams, updateData) => { + const options = { new: true, upsert: true }; return await Action.findOneAndUpdate(searchParams, updateData, options).lean(); }; @@ -49,31 +48,27 @@ const getActions = async (searchParams, includeSensitive = false) => { }; /** - * Deletes an action by params, within a transaction session if provided. + * Deletes an action by params. * * @param {Object} searchParams - The search parameters to find the action to delete. * @param {string} searchParams.action_id - The ID of the action to delete. * @param {string} searchParams.user - The user ID of the action's author. - * @param {mongoose.ClientSession} [session] - The transaction session to use (optional). * @returns {Promise} A promise that resolves to the deleted action document as a plain object, or null if no document was found. */ -const deleteAction = async (searchParams, session = null) => { - const options = session ? { session } : {}; - return await Action.findOneAndDelete(searchParams, options).lean(); +const deleteAction = async (searchParams) => { + return await Action.findOneAndDelete(searchParams).lean(); }; /** - * Deletes actions by params, within a transaction session if provided. + * Deletes actions by params. * * @param {Object} searchParams - The search parameters to find the actions to delete. * @param {string} searchParams.action_id - The ID of the action(s) to delete. * @param {string} searchParams.user - The user ID of the action's author. - * @param {mongoose.ClientSession} [session] - The transaction session to use (optional). * @returns {Promise} A promise that resolves to the number of deleted action documents. */ -const deleteActions = async (searchParams, session = null) => { - const options = session ? { session } : {}; - const result = await Action.deleteMany(searchParams, options); +const deleteActions = async (searchParams) => { + const result = await Action.deleteMany(searchParams); return result.deletedCount; }; diff --git a/api/models/Assistant.js b/api/models/Assistant.js index 2c98287a88..d0e73ad4e7 100644 --- a/api/models/Assistant.js +++ b/api/models/Assistant.js @@ -5,17 +5,16 @@ const Assistant = mongoose.model('assistant', assistantSchema); /** * Update an assistant with new data without overwriting existing properties, - * or create a new assistant if it doesn't exist, within a transaction session if provided. + * or create a new assistant if it doesn't exist. * * @param {Object} searchParams - The search parameters to find the assistant to update. * @param {string} searchParams.assistant_id - The ID of the assistant to update. * @param {string} searchParams.user - The user ID of the assistant's author. * @param {Object} updateData - An object containing the properties to update. - * @param {mongoose.ClientSession} [session] - The transaction session to use (optional). * @returns {Promise} The updated or newly created assistant document as a plain object. */ -const updateAssistantDoc = async (searchParams, updateData, session = null) => { - const options = { new: true, upsert: true, session }; +const updateAssistantDoc = async (searchParams, updateData) => { + const options = { new: true, upsert: true }; return await Assistant.findOneAndUpdate(searchParams, updateData, options).lean(); };