Skip to content
On this page

metaFind

WARNING

This will no longer receive updates in favor of metaQuery


Demo

Should perform simple find

js
const dictionary = {
  name: 'users.name',
  status: 'users.status'
}

const condition = {
  name: 'Jeash',
  status: 'banned'
}

const result = knex('users')
  .metaFind(condition, dictionary)
  .toString()
sql
SELECT
  *
FROM
  `users`
WHERE
  `users`.`name` = 'Jeash'
  AND `users`.`status` = 'banned'
LIMIT
  1

Should ignore items not in dictionary

js
const dictionary = {
  name: 'users.name',
  status: 'users.status'
}

const condition = {
  name: 'Jeash'
}

const result = knex('users')
  .metaFind(condition, dictionary)
  .toString()
sql
SELECT
  *
FROM
  `users`
WHERE
  `users`.`name` = 'Jeash'
LIMIT
  1