DelegateOperation.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. const QueryBuilderOperation = require('./QueryBuilderOperation');
  2. // Operation that simply delegates all calls to the operation passed
  3. // to to the constructor in `opt.delegate`.
  4. class DelegateOperation extends QueryBuilderOperation {
  5. constructor(name, opt) {
  6. super(name, opt);
  7. this.delegate = opt.delegate;
  8. }
  9. is(OperationClass) {
  10. return super.is(OperationClass) || this.delegate.is(OperationClass);
  11. }
  12. onAdd(builder, args) {
  13. return this.delegate.onAdd(builder, args);
  14. }
  15. onBefore1(builder, result) {
  16. return this.delegate.onBefore1(builder, result);
  17. }
  18. hasOnBefore1() {
  19. return this.onBefore1 !== DelegateOperation.prototype.onBefore1 || this.delegate.hasOnBefore1();
  20. }
  21. onBefore2(builder, result) {
  22. return this.delegate.onBefore2(builder, result);
  23. }
  24. hasOnBefore2() {
  25. return this.onBefore2 !== DelegateOperation.prototype.onBefore2 || this.delegate.hasOnBefore2();
  26. }
  27. onBefore3(builder, result) {
  28. return this.delegate.onBefore3(builder, result);
  29. }
  30. hasOnBefore3() {
  31. return this.onBefore3 !== DelegateOperation.prototype.onBefore3 || this.delegate.hasOnBefore3();
  32. }
  33. onBuild(builder) {
  34. return this.delegate.onBuild(builder);
  35. }
  36. hasOnBuild() {
  37. return this.onBuild !== DelegateOperation.prototype.onBuild || this.delegate.hasOnBuild();
  38. }
  39. onBuildKnex(knexBuilder, builder) {
  40. return this.delegate.onBuildKnex(knexBuilder, builder);
  41. }
  42. hasOnBuildKnex() {
  43. return (
  44. this.onBuildKnex !== DelegateOperation.prototype.onBuildKnex || this.delegate.hasOnBuildKnex()
  45. );
  46. }
  47. onRawResult(builder, result) {
  48. return this.delegate.onRawResult(builder, result);
  49. }
  50. hasOnRawResult() {
  51. return (
  52. this.onRawResult !== DelegateOperation.prototype.onRawResult || this.delegate.hasOnRawResult()
  53. );
  54. }
  55. onAfter1(builder, result) {
  56. return this.delegate.onAfter1(builder, result);
  57. }
  58. hasOnAfter1() {
  59. return this.onAfter1 !== DelegateOperation.prototype.onAfter1 || this.delegate.hasOnAfter1();
  60. }
  61. onAfter2(builder, result) {
  62. return this.delegate.onAfter2(builder, result);
  63. }
  64. hasOnAfter2() {
  65. return this.onAfter2 !== DelegateOperation.prototype.onAfter2 || this.delegate.hasOnAfter2();
  66. }
  67. onAfter3(builder, result) {
  68. return this.delegate.onAfter3(builder, result);
  69. }
  70. hasOnAfter3() {
  71. return this.onAfter3 !== DelegateOperation.prototype.onAfter3 || this.delegate.hasOnAfter3();
  72. }
  73. queryExecutor(builder) {
  74. return this.delegate.queryExecutor(builder);
  75. }
  76. hasQueryExecutor() {
  77. return (
  78. this.queryExecutor !== DelegateOperation.prototype.queryExecutor ||
  79. this.delegate.hasQueryExecutor()
  80. );
  81. }
  82. onError(builder, error) {
  83. return this.delegate.onError(builder, error);
  84. }
  85. hasOnError() {
  86. return this.onError !== DelegateOperation.prototype.onError || this.delegate.hasOnError();
  87. }
  88. }
  89. module.exports = DelegateOperation;