To clarify Masoud Tavakkoli's answer (which is not immediately clear on that github answer): using element.get({ plain: true })
returns an array of objects with each attribute key:value pairs.
If you just want an array of one specific attribute's values (eg user ids) instead of objects, you can use something like this:
const users = await User.findAll({
attributes: ["id"],
where: {} // Your filters here
}).map(u => u.get("id")) // [1,2,3]
Nika Kasradze's answer actually achieves the same outcome as a middle-step; using the JSON stringifier generates the same array output. It's possible this is faster than mapping, but I'm not sure.
const users = await User.findAll({
attributes: ["id"],
where: {} // Your filters here
})
const userIds = JSON.stringify(users)) // [1,2,3]