How to set Limit of a relation

I think you want to modify the api::article.article 's create() function logic. and you can add a new customize controller. here is the docs: Backend customization - Controllers - Strapi Developer Docs and there are example in docs.

// path: ./src/api/article/controllers/article.js

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::article.article', ({ strapi }) =>  ({
    async create(ctx) {
        console.log(ctx)
        // you own create logic code here
        // find related article count of ctx.state.user.id, if > N then return message
    }
})
)

Hope it can help you

1 Like