Skip to content

Commit 0bd831f

Browse files
committed
fix: handle inq for referencesMany
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
1 parent 003cfbd commit 0bd831f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎lib/dao.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,24 @@ DataAccessObject.all = function() {
17621762
*/
17631763

17641764
DataAccessObject.find = function find(query, options, cb) {
1765+
const relations = options?.model?.definition?.relations;
1766+
if (query?.where && relations) {
1767+
const { relations } = options['model']['definition'];
1768+
if (relations) {
1769+
for (const key in query.where) {
1770+
// Find if the current 'where' key matches a referencesMany relation's keyFrom
1771+
const matchingRelation = Object.values(relations).find(
1772+
r => r.type === 'referencesMany' && r.keyFrom === key
1773+
);
1774+
if (matchingRelation && query.where[key] && query.where[key].inq) {
1775+
// Mutate the operator from 'inq' to 'jsonContains'
1776+
query.where[key] = {
1777+
jsonContains: query.where[key].inq
1778+
};
1779+
}
1780+
}
1781+
}
1782+
}
17651783
const connectionPromise = stillConnecting(this.getDataSource(), this, arguments);
17661784
if (connectionPromise) {
17671785
return connectionPromise;

0 commit comments

Comments
 (0)