feat(medusa,inventory,types): Expand list-reservation capabilities (#3979)
**What** - Add filter capabilities to reservation items based on: - description query: "contains", "startsWith", "endsWith", "equals" - date querying **How** - Introducing a new filtering primitive: "StringSearchOperator" resembling the "dateComparisonOperator" Fixes CORE-1373
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { ExtendedFindConfig, FindConfig } from "@medusajs/types"
|
||||
import {
|
||||
And,
|
||||
FindManyOptions,
|
||||
@@ -6,6 +5,7 @@ import {
|
||||
FindOptionsRelations,
|
||||
FindOptionsSelect,
|
||||
FindOptionsWhere,
|
||||
ILike,
|
||||
In,
|
||||
IsNull,
|
||||
LessThan,
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
MoreThan,
|
||||
MoreThanOrEqual,
|
||||
} from "typeorm"
|
||||
import { ExtendedFindConfig, FindConfig } from "@medusajs/types"
|
||||
|
||||
import { FindOptionsOrder } from "typeorm/find-options/FindOptionsOrder"
|
||||
import { isObject } from "./is-object"
|
||||
|
||||
@@ -120,6 +122,15 @@ function buildWhere<TWhereKeys extends object, TEntity>(
|
||||
case "gte":
|
||||
where[key].push(MoreThanOrEqual(objectValue))
|
||||
break
|
||||
case "contains":
|
||||
where[key].push(ILike(`%${objectValue}%`))
|
||||
break
|
||||
case "starts_with":
|
||||
where[key].push(ILike(`${objectValue}%`))
|
||||
break
|
||||
case "ends_with":
|
||||
where[key].push(ILike(`%${objectValue}`))
|
||||
break
|
||||
default:
|
||||
if (objectValue != undefined && typeof objectValue === "object") {
|
||||
where[key] = buildWhere<any, TEntity>(objectValue)
|
||||
|
||||
Reference in New Issue
Block a user