fix: remove unused populate

This commit is contained in:
wancat committed 2023-10-14 18:43:22 +08:00
1 parent fe1f595f0f
commit 277a1aec79
1 file changed
+13 -12
+13 -12
View File
@@ -2,25 +2,26 @@ import { Command } from '@linux-odyssey/models'
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export async function errorCommands() { export async function errorCommands() {
const commands = await Command.find({ error: { $ne: '' } }) const commands = await Command.find({
$and: [
{ error: { $exists: true } },
{ error: { $ne: null } },
{ error: { $ne: '' } },
],
})
.populate({ .populate({
path: 'session', path: 'session',
populate: [ populate: { path: 'user' },
{
path: 'user',
},
{ path: 'quest' },
],
}) })
.exec() .exec()
return commands.map(({ command, error, createdAt, session }) => { return commands.map(({ command, error, createdAt, session }) => {
const { user, quest } = session const { user, quest } = session
return { return {
command, command: command.slice(0, 20),
error, error: error.slice(0, 50),
createdAt: createdAt.toLocaleString(), createdAt: createdAt?.toLocaleString(),
user: user.username, user: user?.username,
quest: quest.id, quest,
} }
}) })
} }