UltipaDocs
Try Playground
  • Introduction
  • RESTful API
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • 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
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • 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
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • 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
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • 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
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • 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
    • Result Processing
    • Types Mapping
  1. Docs
  2. /
  3. Ultipa Drivers
  4. /
  5. Database Querying

Database Querying

Request Configuration

All querying methods support an optional request configuration parameter (RequestConfig or InsertRequestConfig) to customize the behavior of requests made to the database. This parameter allows you to specify various settings, such as graphset name, timeout, and host, to tailor your requests according to your needs.

RequestConfig

RequestConfig defines the settings needed when sending non-insert requests to the database.

TypeScript
import { ConnectionPool } from "@ultipa-graph/ultipa-node-sdk";
import { RequestType } from "@ultipa-graph/ultipa-node-sdk/dist/types";

let sdkUsage = async () => {
  //URI example: hosts="mqj4zouys.us-east-1.cloud.ultipa.com:60010"
  let hosts = [
    "192.168.1.85:60061", 
    "192.168.1.86:60061", 
    "192.168.1.87:60061"
  ];
  let username = "***";
  let password = "***";
  let connPool = new ConnectionPool(hosts, username, password);

  let conn = await connPool.getActive();
  let isSuccess = await conn.test();
  console.log(isSuccess);
  
  // Specifies 'amz' as the target graphset and sets to use the leader node of the cluster 
  let requestConfig = <RequestType.RequestConfig>{
    graphSetName: "amz",
    useMaster: true,
  };
  
  let uqlResult = await conn.uql(`find().nodes([1]) as n return n.name`, requestConfig);
  console.log(uqlResult.data?.alias("n.name").asAttrs());  
  
};

sdkUsage().then(console.log).catch(console.log);

RequestConfig has the following fields:

Item
Type
Description
graphSetNamestringName of the graph to use. If not set, use the graphSetName configured when establishing the connection.
timeoutnumberRequest timeout threshold in seconds.
clusterIDstringSpecifies the cluster to use.
timeZonestringThe time zone to use.
timeZoneOffsetnumberThe amount of time that the time zone in use differs from UTC in minutes.
timestampToStringbooleanWhether to convert timestamp to string.
threadNumnumberNumber of threads.
streamStreamReturns the result in stream.
retryobjectThe retry configuration when request fails. Two keys are available: current and max, both of the number type.
useHoststringSends the request to a designated host node, or to a random host node if not set.
useMasterbooleanSends the request to the leader node to guarantee consistency read if set to true.
package_limitnumberThe limit to the number of packages returned.
forceRefreshbooleanWhether to refresh the cluster information.
logUqlbooleanWhether to print the UQL.

InsertRequestConfig

InsertRequestConfig defines the settings needed when sending data insertion or deletion requests to the database.

TypeScript
import { ConnectionPool, ULTIPA } from "@ultipa-graph/ultipa-node-sdk";
import { RequestType } from "@ultipa-graph/ultipa-node-sdk/dist/types";

let sdkUsage = async () => {

  //URI example: hosts="mqj4zouys.us-east-1.cloud.ultipa.com:60010"
  let hosts = [
    "192.168.1.85:60061", 
    "192.168.1.86:60061", 
    "192.168.1.87:60061"
  ];
  let username = "***";
  let password = "***";
  let connPool = new ConnectionPool(hosts, username, password);

  // Connects to the 'default' graphset
  let conn = await connPool.getActive();
  let isSuccess = await conn.test();
  console.log(isSuccess);
  
  let node1 = new ULTIPA.Node();
  node1.schema = "card";
  node1.id = "ULTIPA8000000000000001";
  node1.values = {balance: Number(3235.2)};
  
  let node2 = new ULTIPA.Node();
  node2.schema = "client";
  node2.id = "ULTIPA800000000000000B";
  node2.values = {level: Number(7)};

  let nodes = [node1, node2];

  // Inserts the two nodes above into graphset 'test' under the overwrite mode
  let insertRequestConfig = <RequestType.InsertRequestConfig>{
    graphSetName: "test",
    insertType: ULTIPA.InsertType.INSERT_TYPE_OVERWRITE,
  };
  let uqlResult = await conn.insertNodesBatchAuto(nodes, insertRequestConfig);

  console.log(uqlResult.status.code);
  
};

sdkUsage().then(console.log).catch(console.log);

InsertRequestConfig has the following fields:

Item
Type
Description
graphSetNamestring[]Name of the graph to use. If not set, use the graphSetName configured when establishing the connection.
timeoutnumberRequest timeout threshold in seconds.
clusterIDstringSpecifies the cluster to use.
timeZonestringThe time zone to use.
timeZoneOffsetnumberThe amount of time that the time zone in use differs from UTC in minutes.
timestampToStringbooleanWhether to convert timestamp to string.
threadNumnumberNumber of threads.
streamStreamReturns the result in stream.
retryobjectThe retry configuration when request fails. Two keys are available: current and max, both of the number type.
useHoststringSends the request to a designated host node, or to a random host node if not set.
useMasterbooleanSends the request to the leader node to guarantee consistency read if set to true.
package_limitnumberThe limit to the number of packages returned.
forceRefreshbooleanWhether to refresh the cluster information.
logUqlbooleanWhether to print the UQL.
insertTypeULTIPA.InsertTypeInsert mode (INSERT_TYPE_NORMAL, INSERT_TYPE_UPSERT, INSERT_TYPE_OVERWRITE).
createNodeIfNotExistbooleanWhether to create start/end nodes of an edge if the end nodes do not exist in the graph.
silentbooleanWhether to keep slient after successful insertion.Returns _id and _uuid of the newly inserted data when set to false.