Postgresql – cast uuid to varchar in postgres when I use sequelize

postgresqlsequelize.jsuuid

I have a table with a column named _id of which the type is uuid. I cast the type of _id from uuid to varchar, in order to select the records as follows:

SELECT "_id" FROM "records" WHERE "_id"::"varchar" LIKE '%1010%';

and it works well.

                 _id                  
--------------------------------------
 9a7a36d0-1010-11e5-a475-33082a4698d6
(1 row)

I use sequelize as ORM for operation postgres. how to build the query condition in sequelize?

Best Answer

I write the query condition as follows, and it works well. Is there any better solution?

{where: ['_id::"varchar" like ?', '%1010%']},