-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subquery for where in #13
Comments
Not a design decision :) Will try to find some time to take a look at this coming week. |
Ok I thought it was a design decision because you should be able to do with whereExists everything you can do whereIn(not sure about this anyway). Also this project is the best I found that's pragmatic and really typesafe. It uses knex and just adds typings so it should share the same performance(?). I have a question that's a bit off topic, did you consider opting out from the relationship graph navigation? const query = typedKnex
.query(User)
.innerJoin(i => i.category)
.where(i => i.name, "Hejlsberg")
.select(i => [i.id, i.category.name]);
const oneUser = await query.getSingle();
console.log(oneUser.id); // Ok
console.log(oneUser.category.name); // Ok
console.log(oneUser.name); // Compilation error in this example you can find the category inside the user object but it's hard to move the object user around between functions. function chargeUser(user: User, amount: number, paymentService: PaymentService) {
console.log("charging user: " + user.name )
paymentService.charge(user.billingInfo.user_billing_id, amount)
} Here, is the relationship billingInfo loaded or not? function chargeUser(user: User, billingInfo: BillingInfo, amount: number, paymentService: PaymentService) {
console.log("charging user: " + user.name )
paymentService.charge(billingInfo, amount)
} This method would just make the library type-safer(imo) by not having relationships that may be loaded or may not. Of course this is not something I came out with, this method comes from scala slick that has an in-dept explanation of this Like to know your opinion ^^ |
So the way I envision it, is that the So for example using function chargeUser(user: Pick<User, "name">, billingInfo: Pick<BillingInfo, "relevant"|"properties">, amount: number, paymentService: PaymentService) {
console.log("charging user: " + user.name )
paymentService.charge(billingInfo, amount)
} |
Using a query in |
Yeah honestly as you said, typescript allows us to do things like that so why not. It may become too verbose to use Pick for example when you have nested relations but yeah, passing query result around should be limited. Thanks for the answer ^^ |
Issue type:
[ ] Question
[ ] Bug report
[X] Feature request
[ ] Documentation issue
Database system/driver:
[ ] Postgres
[ ] MSSQL
[ ] MySQL
[ ] MariaDB
[ ] SQLite3
[ ] Oracle
[ ] Amazon Redshift
typed-knex version:
[X]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)I was looking for subquery for whereIn in the apis but it looks like it's not implemented. There is a whereExist with subquery but why no subquery for where in? Is this a todo or a design decision?
The text was updated successfully, but these errors were encountered: