In this below code i have a variable matchData this variable i starting assign the false then
i show my data in else condition after that matchData=true but when i check the variable is
matchData true or false then showing the false again an again...
also see the comment line its also important
when if the matchdata===true after then how can i update the particular filed soo also check this
const a = [
{
Topic: "TRACK",
SID: "1",
GPSlat: "4322",
GPSlong: "104014684",
GPSat: "43788",
GPSspd: "20",
GPShead: "29499222",
GPSepoch: "1638451313",
id:"3q6yxhBxnxVEtyZcAtNX"
}
]
const b = [
{
Topic: "TRACK",
SID: "1",
GPSlat: "4322",
GPSlong: "104014684",
GPSat: "43788",
GPSspd: "20",
GPShead: "29499222",
GPSepoch: "1638451323"
},
{
Topic: "TRACK",
SID: "1",
GPSlat: "4322",
GPSlong: "104014684",
GPSat: "43788",
GPSspd: "20",
GPShead: "29499222",
GPSepoch: "1638451333"
}
]
//--------------------THis is for SID ---------------------------------------
var result = a.filter(o => !b.some(v => v.SID === o.SID)); //
//--------------------THis is for GPSlat ---------------------------------------
var result1 = a.filter(o => !b.some(v => v.GPSlat.substr(0, 4) === o.GPSlat.substr(0, 4)));
//--------------------THis is for GPSlong ---------------------------------------
var result2 = a.filter(o => !b.some(v => v.GPSlong.substr(0, 4) === o.GPSlong.substr(0, 4)))
var DateTime = a.GpSepoch;
//--------------------This is for date and time -----------------------------------
var result3 = a.filter(o => !b.some(v => v.GPSepoch === o.GPSepoch))
var matchData=false;
if (result.length === 0) {
if (result1.length === 0) {
if (result2.length === 0) {
if (result3.length === 0 || matchData=== true)
{
//how can i update this particular result3 data here using id alse soo please check the error and showing whats the right way to update the particular field
this.db.collection(`DevicesData/`).update({'payload.GPSepoch':DateTime}).catch(error =>{
console.log(error,"Error");
});
console.log("hereeeeeee")
}
else
{
console.log(result3,"GPSepoch")
matchData=true;
}
}
else
{
console.log(result2,"GPSlong")
}
}
else
{
console.log(result1,"GPSlat")
}
}
else{
console.log(result,"SID")
}
thank you