Skip to content

Allow registering custom query operators #60

Closed
@techniq

Description

@techniq

It would be useful if you could register your own query operator.

var adapter = new DSSqlAdapter({
  client: 'mysql',
  connection: {
    user: 'root'
  },
  queryOperators: {
    'search': (query, field, value) => {
      return query.whereRaw(`MATCH(${query.raw(field)}) AGAINST(? IN BOOLEAN MODE)`, value)
    },
    '|search': (query, field, value) => {
      return query.orWhereRaw(`MATCH(${query.raw(field)}) AGAINST(? IN BOOLEAN MODE)`, value)
    }
  }
}

They should maybe be executed before the built in operators to allow overriding.
https://github.com/js-data/js-data-sql/blob/0.11.9/src/index.js#L350

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions