Hello guys i'm trying to delete all the data that start with modapp_${message.guild.id}
i try to use :
let money = db.all().filter(a => a.ID.startsWith(`modapp_${message.guild.id}`))
db.delete(money)
but it's give me this error
SQLite3 can only bind numbers, strings, bigints, buffers, and null
can anyone help me pls
If you look at the Quick.db Documentation You will see that .delete()
accepts a key but .all()
gives you an array of values, they do not mention the return type, after looking at the source code it turns out that you get objects with ID and data as properties, you can map the id's and call delete for each one of them
let money = db.all()
.map(entry => entry.ID)
.filter(id => id.startsWith(`modapp_${message.guild.id}`))
money.forEach(db.delete)
Alternatively you could use Array#reduce to only loop once, mentioning this as an alternative since you would otherwise be looping 3 times
let money = db.all().reduce((acc, val) => {
if (val.ID.startsWith(`modapp_${message.guild.id}`)) {
acc.push(val.ID)
}
return acc
}, [])