Custom Query with Strapi V3

Below code can be used in controller:

const knex = strapi.connections.default;
const result = await knex(‘articles_tags__tags_articles as atta’)
.where(‘tag_id’, 2)
.join(‘articles’, ‘atta.article_id’, ‘articles.id’)
.select(‘art…


This content originally appeared on DEV Community and was authored by John Ding

Below code can be used in controller:

const knex = strapi.connections.default;
const result = await knex('articles_tags__tags_articles as atta')
.where('tag_id', 2)
.join('articles', 'atta.article_id', 'articles.id')
.select('articles.*')

https://docs-v3.strapi.io/developer-docs/latest/development/backend-customization.html#queries


This content originally appeared on DEV Community and was authored by John Ding


Print Share Comment Cite Upload Translate Updates
APA

John Ding | Sciencx (2022-04-09T00:46:10+00:00) Custom Query with Strapi V3. Retrieved from https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/

MLA
" » Custom Query with Strapi V3." John Ding | Sciencx - Saturday April 9, 2022, https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/
HARVARD
John Ding | Sciencx Saturday April 9, 2022 » Custom Query with Strapi V3., viewed ,<https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/>
VANCOUVER
John Ding | Sciencx - » Custom Query with Strapi V3. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/
CHICAGO
" » Custom Query with Strapi V3." John Ding | Sciencx - Accessed . https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/
IEEE
" » Custom Query with Strapi V3." John Ding | Sciencx [Online]. Available: https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/. [Accessed: ]
rf:citation
» Custom Query with Strapi V3 | John Ding | Sciencx | https://www.scien.cx/2022/04/09/custom-query-with-strapi-v3/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.