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
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({
path: 'session',
populate: [
{
path: 'user',
},
{ path: 'quest' },
],
populate: { path: 'user' },
})
.exec()
return commands.map(({ command, error, createdAt, session }) => {
const { user, quest } = session
return {
command,
error,
createdAt: createdAt.toLocaleString(),
user: user.username,
quest: quest.id,
command: command.slice(0, 20),
error: error.slice(0, 50),
createdAt: createdAt?.toLocaleString(),
user: user?.username,
quest,
}
})
}