Last active
March 23, 2022 16:30
-
-
Save icnahom/8b31d5bca0ca1aa39305d1bff646adca to your computer and use it in GitHub Desktop.
getting docs by a foreign key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
products = ( | |
await r.table("saved") | |
.order_by(r.desc("saved_at")) | |
.filter(r.row["user_id"] == user_id) | |
.eq_join("product_id", r.table("products")) | |
.map(lambda doc: doc["right"].merge(make_merge_expr)) | |
.limit(25) | |
.run(self.conn) | |
) | |
products = ( | |
await r.table("saved") | |
.order_by(r.desc("saved_at")) | |
.filter(r.row["user_id"] == user_id) | |
.eq_join("product_id", r.table("products"))["right"] | |
.merge(make_merge_expr) | |
.limit(25) | |
.run(self.conn) | |
) | |
# if concat_map use get_all | |
products = ( | |
await r.table("saved") | |
.order_by(r.desc("saved_at")) | |
.filter(r.row["user_id"] == user_id) | |
.map(lambda save: r.table("products").get(save["product_id"])) | |
.merge(make_merge_expr) | |
.limit(25) | |
.run(self.conn) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment