I have some service that return user's data by it's id. User already stored in request(session) - no need to fetch it every time.
The question is what is the best practice for parameter. Id of the user(SOLID) or user object(more validation/typings).
Example:
//...
// this
public async getByUser(user: User) {
return await Transaction.findAll({
where: { userId: user.id }
});
}
// or this
public async getByUser(userId: number) {
return await Transaction.findAll({
where: { userId }
});
}