Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/model-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const operators = {
ilike: 'ILIKE',
nilike: 'NOT ILIKE',
regexp: 'REGEXP',
contains: '@>',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that the operator needs to be supported by other LoopBack db connectors beyond Postgres. Do we have some ideas about the feasibility of other DBs?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raymondfeng This feature is so much needed. We literally had to hack our way into Loopback as we needed it extensively. Please figure out a way to get this merged.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raymondfeng currently i have added it only for postgres db, not sure how we may implement it for other db connectors as well, i may need to look into this..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @raymondfeng that we must keep other connectors in mind when making any changes in juggler.

Is it possible to implement array coercion of contains filter inside the postgresql connector?

In MongoDB, we have the concept of extended operators, see line 507 later in this file.

https://github.com/strongloop/loopback-datasource-juggler/blob/d953eabe30d793642b9268014efc5f4da4633e29/lib/model-utils.js#L507

Can we perhaps use the same mechanism for PostgreSQL?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check into this @bajtos will inform you after analysis.

Copy link
Copy Markdown
Author

@shubhisood shubhisood Sep 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bajtos you are right after using allowExtendedOperators option within postgres connector model, I am able to handle the case for array field filter, we can close this PR after postgres connector specfic PR gets approved.

};

/*
Expand Down Expand Up @@ -449,6 +450,7 @@ ModelUtils._coerce = function(where, options, modelDef) {
case 'inq':
case 'nin':
case 'between':
case 'contains':
try {
val = coerceArray(val);
} catch (e) {
Expand Down