Once the connection is established, you can send requests to query the database through various methods on the Connection
object, categorized as follows:
UQL Execution
|
|
Graphset Management
|
Schema and Property Management
|
Data Insertion and Deletion
|
Query Acceleration
|
Algorithm Management
|
Downloads and Exports
|
Process and Task Management
|
Access Management
|
Others
|
The task specific methods eliminate the need to explicitly write UQL. The following two examples use the Uql()
and ShowNodeProperty()
methods respectively to retrieve the club-member
node schema and print its associated properties. Notice that the latter is easier to write and returns the result as a list of Property
directly. While with Uql()
, you need to extract the data from Response
and cast it into Property
.
// Uses the Uql() method
myTest, err := conn.Uql("show().node_schema(@`club-member`)", requestConfig)
if err != nil {
println(err)
}
nodeInfo, err1 := myTest.Alias("_nodeSchema").AsSchemas()
if err != nil {
println(err1)
}
printers.PrintSchema(nodeInfo)
// Uses the ShowNodeProperty() method
nodeSimp, err2 := conn.ShowNodeProperty("club-member", requestConfig)
if err != nil {
println(err2)
}
if nodeSimp != nil {
for _, item := range nodeSimp {
println(item.Name)
}
}
However, the Uql()
method serves all querying purposes and can be utilized when the task specific methods are not privided, such as for node, edge or path queries.
Lastly, if you are retrieving a large amount of data from the database, it is recommended to use the the UqlStream()
method to processes the result set incrementally.