How to implement pagination on graph edges? #1696
Answered
by
ModPhoenix
ModPhoenix
asked this question in
Q&A
-
Here is an example of a query where I want to add pagination. Here is the code. pub async fn get_node_children<M: Into<model::GetNodeChildren>>(
db: &Database,
model: M,
) -> Result<Vec<model::Node>> {
let model: model::GetNodeChildren = model.into();
// TODO: figure out how to do pagination on graph edges
// "SELECT ->link->({table}.* LIMIT {limit} START {offset}) as children FROM {id}"
let mut response = db
.query(format!(
"SELECT ->link->{table}.* as children FROM {id}",
table = NODE_TABLE,
id = DbId::from_uuid(NODE_TABLE, model.id),
// limit = model.limit,
// offset = model.offset
))
.await?;
let data: Option<NodeChildren> = response.take(0)?;
Ok(data.ok_or(DataError::NotFound)?.children)
} Maybe the query that i wrote is completely wrong 😑, any help would be appreciated |
Beta Was this translation helpful? Give feedback.
Answered by
ModPhoenix
Mar 11, 2023
Replies: 1 comment
-
I found these two issues that help me with my question #1653, #1658 let mut response = db
.query("SELECT * FROM $id->link->node LIMIT $limit START $offset")
.bind(model)
.await?; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ModPhoenix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found these two issues that help me with my question #1653, #1658