I am working on an API with adonis.js and would like to return the count based on a relationship after creating a new record, example:
const data = request.only(['name']) const category = await BlogCategory.create(data) await category.loadCount('posts') //It does not work return category
For what purpose would I like to do this? since count will always be zero?
I want to return a default category structure for the front end, for example
in the array that holds the category listing, each category has the blog count, when it is a new category it must have the same structure no matter if it has
The only way to solve this would be to use
withCount('posts') in a new database search?