@ -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;
|
||||
|
Reference in New Issue
Block a user