UNPKG

tuain-ecosystem-lib

Version:

Servicio de gestión mensajería instantanea de la plataforma Tuain

80 lines (71 loc) 1.5 kB
const common = require('./common'); function addParamOptionAttribute(name, code, attributeName, attributeValue) { return [ { name, 'options.code': code }, { $addToSet: { 'options.$.attributes': { name: attributeName, value: attributeValue, }, }, }, ]; } function findParams() { return {}; } function modifyOption(name, code, optionData) { const updateData = {}; Object.keys(optionData).forEach((optionField) => { const setKey = `options.$.${optionField}`; updateData[setKey] = optionData[optionField]; }); return [ { name, 'options.code': code }, { $set: updateData }, ]; } function removeParamOptionAttribute(name, code, attributeName) { return [ { name, 'options.code': code }, { $pull: { 'options.$.attributes': { name: attributeName }, }, }, ]; } function addParameterOptionTag(name, code, tag) { return [ { name, 'options.code': code }, { $addToSet: { 'options.$.tags': tag, }, }, ]; } function removeParamOptionTag(name, code, tag) { return [ { name, 'options.code': code }, { $pull: { 'options.$.tags': tag, }, }, ]; } function updateObject(updateData) { return { $set: { ...updateData } }; } module.exports = { ...common, updateObject, findParams, modifyOption, addParamOptionAttribute, removeParamOptionAttribute, addParameterOptionTag, removeParamOptionTag, };