Server Connection and Authentication
import { ConnectionPool } from "@ultipa/ultipa-node-sdk";
// Declare Ultipa cluster addresses
let hosts = [
"192.168.1.11:60061",
"192.168.1.12:60061",
"192.168.1.13:60061"
]
let username = "******"
let password = "******"
// Ultipa connection pool
let connPool = new ConnectionPool(hosts, username, password)
// Create Ultipa Client and test connection
let client = await connPool.getActive()
let isSuccess = await client.test()
console.log(isSuccess);
Acquire Ultipa Client Connection
- The
client
appeared in the rest of this manual represents the Ultipa Client created from ConnectionPool
, this procedure will be omitted in the examples hereafter.
let client = await connPool.getActive()
UQL Example
// eg: find nodes in graphset 'default'
let uqlResult = await client.uql(`find().nodes() as n return n{*} limit 3`, {
graphSetName: "default"
})
if (uqlResult.status.code === ULTIPA.Code.SUCCESS) {
// success
console.log(uqlResult.data);
} else {
console.log(uqlResult.status);
}