Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequelize support for ~ operator with postgres ltree queries

I have a simple postgres ltree query

select * from data_objects WHERE path ~ 'root.*{1}';

I would like to implement this in sequelize, but there is no mapping for the ~ operator.

Is it possible to override the mappings? or do I have to use a raw sql query?

like image 310
Click Ahead Avatar asked Aug 30 '26 11:08

Click Ahead


1 Answers

Found the solution:

params.path = {
        $regexp:'root.*{1}'
};

Which translates as

where "path" ~ 'root.*{1}'

I hadn't seen the $regexp operator

like image 188
Click Ahead Avatar answered Sep 01 '26 04:09

Click Ahead



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!