Do we have any way other than using raw sql query to load data from a junction table? What I want to do is simply check for the existence of the specifiedid
.
My use-case: it's a junction table for likes and I want to check if an user has liked an article. So the query I want to use
SELECT * FROM "article_likes_user" WHERE "articleId" = :articleId AND "userId" = :userId
There is no at the moment. But I plan to implement such functions in the RelationQueryBuilder
in the future. Something like this:
const isUserLiked = await connection.createQueryBuilder(Article)
.relation("likedUsers")
.has(user)
.execute();
You can implement it on your own if you want
Relational query builder functionality is implemented in latest version, you can find docs on site.
Sorry, is this feature still working in? I can't find the method .has
in RelationQueryBuilder.ts
There is no at the moment. But I plan to implement such functions in the
RelationQueryBuilder
in the future. Something like this:const isUserLiked = await connection.createQueryBuilder(Article) .relation("likedUsers") .has(user) .execute();
You can implement it on your own if you want
Most helpful comment
There is no at the moment. But I plan to implement such functions in the
RelationQueryBuilder
in the future. Something like this:You can implement it on your own if you want