How I can set an alias for `__meta__` in withCount relation output?

Hi all
How I can set an alias for __meta__ in withCount relation output?
I want to change __meta__ to another key name

Simply rename the property as follows:

const collection = await SomeModel.withCount('relation').fetch()

return collection.toJSON().map((row) => {
   row.yourPropertyName = row.__meta__
   delete row.__meta__

   return row
})

I have plans to improve this behavior in the future

2 Likes