changes in connections

master
varun 1 year ago
parent 6ca372fed0
commit 783495fd02

@ -506,6 +506,7 @@ const fastify = require("fastify")({
// }; // };
exports.createConnections = async (req, body) => { exports.createConnections = async (req, body) => {
try { try {
const customerId = req.params.customerId; const customerId = req.params.customerId;
@ -560,7 +561,7 @@ exports.createConnections = async (req, body) => {
if (sump_names.includes(tankname)) { if (sump_names.includes(tankname)) {
console.log(`${tankname} exists in ${sump_names}`); console.log(`${tankname} exists in ${sump_names}`);
} else { } else {
const tank_info1 = await Tank.findOne({ customerId: customerId.toString(), tankName: tankname }); console.log(tankInfo,"areyyy")
const tankConnections = await Tank.findOneAndUpdate( const tankConnections = await Tank.findOneAndUpdate(
{ customerId: customerId.toString(), tankName: tankName }, { customerId: customerId.toString(), tankName: tankName },
{ {
@ -569,14 +570,16 @@ exports.createConnections = async (req, body) => {
$each: [{ $each: [{
inputConnections: tankname, inputConnections: tankname,
input_type: 'sump', input_type: 'sump',
inputismotor: true || false, inputismotor: data.outputismotor || false,
motor_id: motorId || null, motor_id: data.motor_id || null,
water_level: tank_info1.waterlevel || null, water_level: tankInfo.waterlevel || null,
capacity: tank_info1.capacity || null, capacity: tankInfo.capacity || null,
motor_status: data.motor_status || "1", motor_status: data.motor_status || "0",
motor_stop_status: data.motor_stop_status || "1" motor_stop_status: data.motor_stop_status || "1"
}], }], },
}, // 'connections.outputConnections': {
// $each: [{ outputConnections: tankname, output_type: 'overhead'}],
// },
}, },
}, },
{ new: true } { new: true }
@ -587,8 +590,7 @@ exports.createConnections = async (req, body) => {
} }
} }
return tank_connections;
} catch (err) { } catch (err) {
throw boom.boomify(err); throw boom.boomify(err);
} }

Loading…
Cancel
Save