// Users older than 18FilterExpr::gt("age",Value::Int32(18))// Users with age between 18 and 30FilterExpr::and(vec![FilterExpr::ge("age",Value::Int32(18)),FilterExpr::le("age",Value::Int32(30)),])
// Users older than 18{field:"age",op:"gt",value:18}// Users with age between 18 and 30{and:[{field:"age",op:"ge",value:18},{field:"age",op:"le",value:30},]}
# Users older than 18{"field":"age","op":"gt","value":18}# Users with age between 18 and 30{"and":[{"field":"age","op":"ge","value":18},{"field":"age","op":"le","value":30},]}
useormdb_proto::RelationInclude;// Load users with their postsletquery=GraphQuery::new("User").include(RelationInclude::new("posts"));
constresult=awaitclient.query("User",{includes:[{relation:"posts"}],});// Access related datafor(constuserofresult.entities){console.log(`${user.name} has ${user.posts?.length||0} posts`);}
result=client.query("User",includes=[{"relation":"posts"}])foruserinresult.entities:print(f"{user['name']} has {len(user.get('posts',[]))} posts")
// Only include published postsletquery=GraphQuery::new("User").include(RelationInclude::new("posts").with_filter(FilterExpr::eq("published",Value::Bool(true))));
useormdb_proto::OrderSpec;// Sort by name ascendingletquery=GraphQuery::new("User").with_order(OrderSpec::asc("name"));// Sort by created_at descendingletquery=GraphQuery::new("User").with_order(OrderSpec::desc("created_at"));// Multiple sort keysletquery=GraphQuery::new("User").with_orders(vec![OrderSpec::asc("status"),OrderSpec::desc("created_at"),]);
// Sort by name ascendingconstresult=awaitclient.query("User",{orderBy:[{field:"name",direction:"asc"}],});// Multiple sort keysconstresult=awaitclient.query("User",{orderBy:[{field:"status",direction:"asc"},{field:"created_at",direction:"desc"},],});
# Sort by name ascendingresult=client.query("User",order_by=[{"field":"name","direction":"asc"}])# Multiple sort keysresult=client.query("User",order_by=[{"field":"status","direction":"asc"},{"field":"created_at","direction":"desc"},])
useormdb_proto::Pagination;// First 10 usersletquery=GraphQuery::new("User").with_pagination(Pagination::new(10,0));// limit, offset// Next 10 usersletquery=GraphQuery::new("User").with_pagination(Pagination::new(10,10));
// First 10 usersconstresult=awaitclient.query("User",{limit:10,offset:0,});// Check if there are moreif(result.hasMore){// Fetch next page}
# First 10 usersresult=client.query("User",limit=10,offset=0)# Check if there are moreifresult.has_more:# Fetch next pagepass
useormdb_core::query::FanoutBudget;letbudget=FanoutBudget{max_entities:1000,// Max total entitiesmax_edges:5000,// Max relation edgesmax_depth:3,// Max include nesting};letresult=executor.execute_with_budget(&query,budget)?;