Thursday, 25 May 2017

Adonis.js search queries

I'm trying to find a way to execute a search query using adonis.js but I cannot find any way to do this with Lucid ORM...

I'm currently using this, but it's clearly not the right way to make a search query:

let posts = yield Post.query().with('category').where({
   title: request.input('term')
}).forPage(1, 10).fetch()

How can I directly execute postgres SQL queries using adonis.js framework?

SELECT id FROM posts WHERE content LIKE '%searchterm%' OR WHERE tags LIKE '%searchterm%' OR WHERE title LIKE '%searchterm%'

Thank you in advance



via hailton

No comments:

Post a Comment