Home > front end >  Escaping hyphens(-) in uuid for checking against values in database [closed]
Escaping hyphens(-) in uuid for checking against values in database [closed]

Time:09-27

I have a query that checks against values in the database with UUID. Now the problem is the - that come in between the UUIDs.

I am doing something like

async getRecurringOrderCount(orderId: string) {
        return await this.createQueryBuilder()
            .where("parent_id = :orderId", {orderId})
            .andWhere("order_status_id = \'bd8c82ee-a9ae-48a6-b4c2-23ca0d39f55c\'") // this will  check inclusive of '' which will never get me a result
            //.orWhere("order_status_id = \'949438ca-fb6a-48bb-be2c-6a181cf5a9e1\'")
            .getCount()
    }

And in my database i have values stored as string like this bd8c82ee-a9ae-48a6-b4c2-23ca0d39f55c

Is there any solution for this?

CodePudding user response:

You can simply use this to refrain typeorm from using your ''.

    async getRecurringOrderCount(orderId: string) {
        return await this.createQueryBuilder()
            .where("parent_id = :orderId", {orderId})
            .andWhere("order_status_id = :orderStatusId", {orderStatusId:'bd8c82ee-a9ae-48a6-b4c2-23ca0d39f55c'})
            .getCount()
    }

It will replace orderStatusId with the value provided.

  • Related