2020-04-08 22:05:53 +02:00
|
|
|
import _ from "lodash";
|
|
|
|
|
2022-08-23 20:08:53 +02:00
|
|
|
export function inCondition<T>(
|
|
|
|
field: string,
|
|
|
|
list: T[]
|
|
|
|
): { query: string; params: T[] } {
|
2020-04-08 22:05:53 +02:00
|
|
|
return {
|
2022-08-23 20:08:53 +02:00
|
|
|
query:
|
|
|
|
"(" +
|
|
|
|
field +
|
|
|
|
" IN (" +
|
|
|
|
_.times(list.length, () => "?").join(", ") +
|
|
|
|
"))",
|
2020-04-08 22:05:53 +02:00
|
|
|
params: list,
|
2022-08-23 20:08:53 +02:00
|
|
|
};
|
2020-04-08 22:05:53 +02:00
|
|
|
}
|