How do I return only selected certain fields in Strapi?

后端 未结 5 1579
独厮守ぢ
独厮守ぢ 2021-01-18 06:16

Pretty straightforward (I hope). I\'d like to be able to use the API endpoint and have it only return specified fields. I.E. something like this

http://local         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 06:55

    You can use the select function if you are using MongoDB Database:
    await strapi.query('game-category').model.find().select(["Code"])
    As you can see, I have a model called game-category and I just need the "Code" field so I used the Select function.

提交回复
热议问题