lundi 19 avril 2021

Mock Typeorm QueryBuilder

I need to test a call like this:

    const connection = await getConnection('default');
    const queryBuilder = connection
        .createQueryBuilder(Reading, 'r')
        .where("r.code = :code AND um = 'KWH'", { code: meter.code })
        .andWhere(" measure_date BETWEEN to_date(:startDate,'YYYY-MM-DD') AND to_date(:endDate,'YYYY-MM-DD')", {
            startDate,
            endDate,
        })
        .andWhere('r.deleted_at IS NULL')
        .orderBy('r.measure_date', 'DESC')
        .addOrderBy('r.reading_type')
        .addOrderBy('r.band', 'ASC');

    const readings = await queryBuilder.getMany();

i tried many solutions, but none worked. any suggestions?

thx to all

Aucun commentaire:

Enregistrer un commentaire