I want to get the result from filter of db but I got undefined and I don't know why.
const IDD = discordsearchf
const all = (await client.db.all()).filter(data => data.id.startsWith("tickets_"));
const mfilter = all.filter(data => data.value.creator === IDD && data.value.createdAt == '1678356812821');
const efilter = mfilter.filter(data => data.value.closedBy)
console.log(efilter)
Here I got undefined:
const efilter = mfilter.filter(data => data.value.closedBy)
console.log(efilter)
Here is cmd for console log mfilter:
[
{
id: 'tickets_1083331733912559716',
value: {
id: 136,
category: [Object],
reason: 'No reason provided',
creator: '909068597089959976',
invited: [],
createdAt: 1678356812821,
claimed: false,
claimedBy: null,
claimedAt: null,
closed: true,
closedBy: '715637000669102171',
closedAt: 1678562559496,
acceptedby: '846304823595106304',
messageId: '1083331735191814184',
closeReason: 'No REASON'
}
}
]
I tried value.closedBy, data.value.closedBy, and mfilter.closedBy.
Try replacing
mfilterwith this line:data.value.createdAthere is a Number and as I can see in your code you used the string quotes' 'when checking the filter conditiondata.value.createdAt == '1678356812821'.So removing the string quotes would probably solve the problem. Your code should look now like this: