Home>

Tell me please, I'm looking for in the database table all except where Status is not 1 and not 4

Const Orders= Await this.orderRePository.find ({
      Status: not (1),
    });

Here I'm looking for everything where Status is not 1, but I need to look for everything that is not 1 and not 4 how to do it? did like that

Const Orders= Await this.orderRePository.find ({
      Status: not (1,4),
    });

But so gives an error how to do it?

  • Answer # 1

    you need to use simultaneously Advanced Options. Not. and IN. :

    Const Orders= Await this.orderRePository.find ({
      Status: Not (In ([1, 4])),
    });
    

    Since you write on, it will be convenient to useenum , instead of a digital value of the order status, for example,

    Export ENUM ORDERSTATUS {
      new
      COMPLETE,
      PAID
      Done
      refund
    }
    

    And then any other programmer will understand your request more correctly and faster:

    Const Conditions: FindConditions <
    Order >
    = {
      Status: Not (In ([
        OrderStatus.comPlete,
        OrderStatus.Refund
      ])
    };
    Const Orders= Await this.orderRePository.find (Conditions);
    

    An excellent answer, and more and more detailed, thank you!

    Овов Очоы2021-08-27 17:10:53

    Would you help you still with some question?

    Овов Очоы2021-08-27 17:26:25
  • Answer # 2

    you need to use simultaneously Advanced Options. Not. and IN. :

    Const Orders= Await this.orderRePository.find ({
      Status: Not (In ([1, 4])),
    });
    

    Since you write on, it will be convenient to useenum , instead of a digital value of the order status, for example,

    Export ENUM ORDERSTATUS {
      new
      COMPLETE,
      PAID
      Done
      refund
    }
    

    And then any other programmer will understand your request more correctly and faster:

    Const Conditions: FindConditions <
    Order >
    = {
      Status: Not (In ([
        OrderStatus.comPlete,
        OrderStatus.Refund
      ])
    };
    Const Orders= Await this.orderRePository.find (Conditions);
    

    An excellent answer, and more and more detailed, thank you!

    Овов Очоы2021-08-27 17:10:53

    Would you help you still with some question?

    Овов Очоы2021-08-27 17:26:25