mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-17 09:05:56 +00:00
fix: cast getParent and getChildren to Beans
This commit is contained in:
parent
71c7ee69c7
commit
c079971a7b
1 changed files with 10 additions and 5 deletions
|
@ -1629,10 +1629,10 @@ class Monitor extends BeanModel {
|
||||||
/**
|
/**
|
||||||
* Gets Parent of the monitor
|
* Gets Parent of the monitor
|
||||||
* @param {number} monitorID ID of monitor to get
|
* @param {number} monitorID ID of monitor to get
|
||||||
* @returns {Promise<LooseObject<any>>} Parent
|
* @returns {Promise<Bean | null>} Parent
|
||||||
*/
|
*/
|
||||||
static async getParent(monitorID) {
|
static async getParent(monitorID) {
|
||||||
return await R.getRow(`
|
const result = await R.getRow(`
|
||||||
SELECT parent.* FROM monitor parent
|
SELECT parent.* FROM monitor parent
|
||||||
LEFT JOIN monitor child
|
LEFT JOIN monitor child
|
||||||
ON child.parent = parent.id
|
ON child.parent = parent.id
|
||||||
|
@ -1640,20 +1640,25 @@ class Monitor extends BeanModel {
|
||||||
`, [
|
`, [
|
||||||
monitorID,
|
monitorID,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return R.convertToBean("monitor", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all Children of the monitor
|
* Gets all Children of the monitor
|
||||||
* @param {number} monitorID ID of monitor to get
|
* @param {number} monitorID ID of monitor to get
|
||||||
* @returns {Promise<LooseObject<any>>} Children
|
* @returns {Promise<Bean[]>} Children
|
||||||
*/
|
*/
|
||||||
static async getChildren(monitorID) {
|
static async getChildren(monitorID) {
|
||||||
return await R.getAll(`
|
return R.convertToBeans("monitor", await R.getAll(`
|
||||||
SELECT * FROM monitor
|
SELECT * FROM monitor
|
||||||
WHERE parent = ?
|
WHERE parent = ?
|
||||||
`, [
|
`, [
|
||||||
monitorID,
|
monitorID,
|
||||||
]);
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue