Working with LB4 framework and Postgres for DB, using "loopback-connector-postgresql": "^3.7.0" for DB connectivity and facing issue while using find query with where operator to fetch list of data by matching value in an array and the query used is shared below,
sample table data:
[{id: 1,
roll: [1,4]
},{
id:2,
roll: [1,3],
},{
id:3,
roll: [2,4]
}]
In model roll marked mandatory
Query used:
this.repository.find({where: { roll: { inq: [4] }}});
Expected output:
[{id: 1,
roll: [1,4]
},{
id:3,
roll: [2,4]
}]
for the above code snippet typescript in loopback4 throws the below error
*Argument of type '{ where: { roll: { inq: number[]; }; }; }' is not assignable to parameter of type 'Filter<ModelRow>'.
Types of property 'where' are incompatible.
Type '{ row: { inq: number[]; }; }' is not assignable to type 'Condition<ModelRow> | AndClause<ModelRow> | OrClause<ModelRow> | undefined'.
Type '{ row: { inq: number[]; }; }' is not assignable to type 'Condition<ModelRow>'.
Types of property 'row' are incompatible.
Type '{ inq: number[]; }' is not assignable to type 'PredicateComparison<number[]> | (number[] & string) | (number[] & number) | (number[] & false) | (number[] & true) | (number[] & Date) | undefined'.
Type '{ inq: number[]; }' is not assignable to type 'undefined'.ts(2345)*