mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-09 01:32:02 +08:00
[status page] many update and save group list
This commit is contained in:
33
server/model/group.js
Normal file
33
server/model/group.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const { BeanModel } = require("redbean-node/dist/bean-model");
|
||||
const { R } = require("redbean-node");
|
||||
|
||||
class Group extends BeanModel {
|
||||
|
||||
async toPublicJSON() {
|
||||
|
||||
let monitorBeanList = R.convertToBeans("monitor", await R.getAll(`
|
||||
SELECT * FROM monitor, monitor_group
|
||||
WHERE monitor.id = monitor_group.monitor_id
|
||||
AND group_id = ?
|
||||
`, [
|
||||
this.id,
|
||||
]));
|
||||
|
||||
console.log(monitorBeanList);
|
||||
|
||||
let monitorList = [];
|
||||
|
||||
for (let bean of monitorBeanList) {
|
||||
monitorList.push(await bean.toPublicJSON());
|
||||
}
|
||||
|
||||
return {
|
||||
id: this.id,
|
||||
name: this.name,
|
||||
weight: this.weight,
|
||||
monitorList,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Group;
|
Reference in New Issue
Block a user