I’m not sure what you want to achieve, but if you want to get the IDs of all the references in a field.
To somethink like that:
// Get Multi-Item Reference ID
async function getReferenceID(database, referenceField) {
const res = await wixData.query(database)
.include(referenceField)
.find();
return res.items.map(e => e._id );
}