store neighbour info directly in the nodes table
This commit is contained in:
21
src/mqtt.js
21
src/mqtt.js
@ -273,6 +273,7 @@ client.on("message", async (topic, message) => {
|
||||
});
|
||||
}
|
||||
|
||||
// create neighbour info
|
||||
try {
|
||||
await prisma.neighbourInfo.create({
|
||||
data: {
|
||||
@ -290,6 +291,26 @@ client.on("message", async (topic, message) => {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// update node neighbour info in db
|
||||
try {
|
||||
await prisma.node.updateMany({
|
||||
where: {
|
||||
node_id: envelope.packet.from,
|
||||
},
|
||||
data: {
|
||||
neighbour_broadcast_interval_secs: neighbourInfo.nodeBroadcastIntervalSecs,
|
||||
neighbours: neighbourInfo.neighbors.map((neighbour) => {
|
||||
return {
|
||||
node_id: neighbour.nodeId,
|
||||
snr: neighbour.snr,
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if(portnum === 67) {
|
||||
|
Reference in New Issue
Block a user