WhereJsonPostgresOperation.js 644 B

123456789101112131415161718192021
  1. const jsonApi = require('./postgresJsonApi');
  2. const ObjectionToKnexConvertingOperation = require('../ObjectionToKnexConvertingOperation');
  3. class WhereJsonPostgresOperation extends ObjectionToKnexConvertingOperation {
  4. onBuildKnex(knexBuilder) {
  5. const rawArgs = jsonApi.whereJsonbRefOnLeftJsonbValOrRefOnRightRawQueryParams(
  6. this.args[0],
  7. this.opt.operator,
  8. this.args[1],
  9. this.opt.prefix
  10. );
  11. if (this.opt.bool === 'or') {
  12. knexBuilder.orWhereRaw.apply(knexBuilder, rawArgs);
  13. } else {
  14. knexBuilder.whereRaw.apply(knexBuilder, rawArgs);
  15. }
  16. }
  17. }
  18. module.exports = WhereJsonPostgresOperation;