Advertisement
the0938

Repo Select And Join

Jan 6th, 2022
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const findUserWithItsAssets = (userId) =>
  2.   UserRepo.select()
  3.     .where((user) => user.id(id))
  4.     .join((users) =>
  5.       AssetRepo.select().where((asset) =>
  6.         asset.belongsToCompany((company) => company.hasUser(users))
  7.       )
  8.     )
  9.     .execute();
  10.  
  11. // Should return
  12. // [User, [Asset]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement