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?
The uuid-ossp module provides additional functions that implement other standard algorithms for generating UUIDs. PostgreSQL also provides the usual comparison operators shown in Table 9.1 for UUIDs.
The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 4122, ISO/IEC 9834-8:2005, and related standards. (Some systems refer to this data type as a globally unique identifier, or GUID, instead.)
I write the query condition as follows, and it works well. Is there any better solution?
{where: ['_id::"varchar" like ?', '%1010%']},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With