1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-01 15:45:58 +09:00

Improve log api

This commit is contained in:
syuilo 2019-03-03 08:13:49 +09:00
parent 60c30ece10
commit 3c77ae7b62
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69

View File

@ -34,11 +34,27 @@ export default define(meta, async (ps) => {
if (ps.level) query.level = ps.level;
if (ps.domain) {
for (const d of ps.domain.split(' ')) {
const qs: any[] = [];
let i = 0;
for (const d of ps.domain.split('.')) {
query[`domain.${i}`] = d;
for (const sd of (d.startsWith('-') ? d.substr(1) : d).split('.')) {
qs.push({
[`domain.${i}`]: d.startsWith('-') ? { $ne: sd } : sd
});
i++;
}
if (d.startsWith('-')) {
if (query['$and'] == null) query['$and'] = [];
query['$and'].push({
$and: qs
});
} else {
if (query['$or'] == null) query['$or'] = [];
query['$or'].push({
$and: qs
});
}
}
}
const logs = await Log