Skip to content

[FEATURE]: Add "JsonContains" operator #9664

@dzvyagin

Description

@dzvyagin

Feature Description

The PostgreSQL database was found to be searching in a column with the type "Json" or "Jsonb". Now, in order to search with typeorm, you need to create a queryBuilder and describe the query with the passed parameters.

The Solution

The postgreSQL operator "@>" can be used to solve the json column search problem. To conveniently abstract from the use of the postgreSQL statement, the plan is to create a findOperator "JsonContains" to help solve the json search problem.

this.repo.find({
    where: { id: In(ids), address: JsonContains({ city: { id: 12 } }) },
});

Considered Alternatives

One alternative is to create a query builder and describe the sql query in it.

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions