Took 28 minutes
This commit is contained in:
2023-02-02 08:32:22 +01:00
parent 59bb0437e1
commit 02c335bc27
2 changed files with 20 additions and 15 deletions

View File

@ -50,12 +50,22 @@ router.ws('/', async (ws, req, next) => {
switch (msg.event) {
case WebSocketEvent.CONTAINERS: {
let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; useProxy: boolean }[];
await Container.deleteMany({}); // V2: Remove this and check every container based on id if changes occurs
let data = msg.data as { id?: string, pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; useProxy: boolean }[];
// await Container.deleteMany({}); // V2: Remove this and check every container based on id if changes occurs
let i = 0;
for (let c of data) {
let container = new Container();
let container : IContainer | null = null;
if( c.id )
{
container = await Container.findOne( {_id: c.id } );
}
if( !container )
container = new Container();
container.slot = i;
//container.volume = c.volume; // V2: Removed
container.pumpPin = c.pumpPin;