增加cron搜索

This commit is contained in:
whyour
2021-04-04 14:27:09 +08:00
parent f46e20fc81
commit a7d652c86e
3 changed files with 34 additions and 5 deletions
+16 -2
View File
@@ -48,10 +48,24 @@ export default class CronService {
await this.set_crontab();
}
public async crontabs(): Promise<Crontab[]> {
public async crontabs(searchText?: string): Promise<Crontab[]> {
let query = {};
if (searchText) {
const reg = new RegExp(searchText);
query = {
$or: [
{
name: reg,
},
{
command: reg,
},
],
};
}
return new Promise((resolve) => {
this.cronDb
.find({})
.find(query)
.sort({ created: -1 })
.exec((err, docs) => {
resolve(docs);