Skip to content

wintexpro/typeorm-nested-where

Repository files navigation

Nested relations filtering for Typeorm repositories. Warning: works with typeorm v.2.2.5. For other versions is not checked.

Function whereToRaw can convert your find conditions to raw SQL string. After that you can use this string in repository query.

Example:

const whereConditions: FindConditions<Pet> = {
    name: 'Mike',
    owner: {
        age: 20,
        status: In(['a', 'b']),
    } as FindConditions<User>,
};

// convert conditions to raw SQL string
const rawWhere = whereToRaw('Pet', whereConditions, 'snake_to_camelcase'));

const count = await getConnection().getRepository(Pet).find({
    where: rawWhere,
    relations: ['owner']
});

About

Nested relations filtering for Typeorm repositories

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published