navy
navy

Reputation: 169

How to filter by ILIKE word in gino with Postgres

I want to implement a suggest search in my project. I use a gino library and wondering how to code a "like" filter in gino code?

Basically i need to write this sql statement in gino code:

SELECT id FROM category WHERE category.name ILIKE '%query%' 

Cant find anything in gino docs.

Upvotes: 2

Views: 389

Answers (1)

fromSelect
fromSelect

Reputation: 23

At gino main page we can see in examples:

users = await User.query.where(User.nickname.contains("d")).gino.all()

so you can try something like that:

category_obj = await CategiryModel.query.where(
CategiryModel.name.ilike("some_name")
).gino.first()


print(category_obj.id)

And you need to make CategiryModel first.

It's actually a SQLAlchemy query

Upvotes: 1

Related Questions