Change Password

Please enter the password.
Please enter the password. Between 8-64 characters. Not identical to your email address. Contain at least 3 of: uppercase, lowercase, numbers, and special characters.
Please enter the password.
Submit

Change Nickname

Current Nickname:
Submit

Apply New License

License Detail

Please complete this required field.

  • Ultipa Blaze (v4)

Standalone

Please complete this required field.

Please complete this required field.

Please complete this required field.

Please complete this required field.

Leave it blank if an HDC service is not required.

Please complete this required field.

Leave it blank if an HDC service is not required.

Please complete this required field.

Please complete this required field.

Mac addresses of all servers, separated by line break or comma.

Please complete this required field.

Please complete this required field.

Cancel
Apply
ID
Product
Status
Cores
Maximum Shard Services
Maximum Total Cores for Shard Service
Maximum HDC Services
Maximum Total Cores for HDC Service
Applied Validity Period(days)
Effective Date
Expired Date
Mac Address
Reason for Application
Review Comment
Close
Profile
  • Full Name:
  • Phone:
  • Company:
  • Company Email:
  • Country:
  • Language:
Change Password
Apply

You have no license application record.

Apply
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

Product Created On ID Amount (USD) Invoice
Product Created On ID Amount (USD) Invoice

No Invoice

v5.0
Search
    English
    v5.0

      Graph

      This section introduces methods for managing graphs in the database.

      showGraph()

      Retrieves all graphs from the database.

      Parameters

      • config: RequestConfig (Optional): Request configuration.

      Returns

      • GraphSet[]: The list of retrieved graphs.

      // Retrieves all graphs and prints the names of those with over 2000 edges
      
      const graphs = await conn.showGraph();
      graphs
        .filter((graph) => Number(graph.totalEdges) > 2000)
        .forEach((graph) => console.log(graph.name));
      

      Display_Ad_Click
      ERP_DATA2
      wikiKG
      

      getGraph()

      Retrieves a specified graph from the database.

      Parameters

      • graphName: string: Name of the graph.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • GraphSet: The retrieved graph.

      // Retrieves the graph named 'miniCircle'
      
      const graph = await conn.getGraph("miniCircle");
      console.log(graph);
      

      {"id": "444", "name": "miniCircle", "totalNodes": 304, "totalEdges": 1961, "shards": ["1"], "partitionBy": "CityHash64", "status": "NORMAL", "description": "", "slotNum": 256}
      

      hasGraph()

      Checks the existence of a specified graph in the database.

      Parameters

      • graphName: string: Name of the graph.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • boolean: Check result.

      // Checks the existence of a graph named 'miniCircle'
      
      const response = await conn.hasGraph("miniCircle");
      console.log("The graph exists:", response);
      

      The graph exists: true
      

      createGraph()

      Creates a graph in the database.

      Parameters

      • graphSet: GraphSet: The graph to be created; the attribute name is mandatory, shards, partitionBy and description are optional.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • Response: Response of the request.

      // Creates a graph
      
      const graph: GraphSet = {
        name: "testNodejsSDK",
        shards: ["1"],
        partitionBy: "Crc32",
        description: "testNodejsSDK desc"
      };
      const response = await conn.createGraph(graph)
      console.log(response.status?.message);
      

      SUCCESS
      

      createGraphIfNotExist()

      Creates a graph in the database and returns whether a graph with the same name already exists.

      Parameters

      • graphSet: GraphSet: The graph to be created; the attribute name is mandatory, shards, partitionBy and description are optional.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • ResponseWithExistCheck: Response of the request.

      const graph:GraphSet = {
        name:"testNodejsSDK",
        shards:["1"],
        partitionBy:"Crc32",
        description:"testNodejsSDK desc"
      }
      
      const result = await conn.createGraphIfNotExist(graph)
      
      console.log("Does the graph already exist?", result.exist)
      if(result.response.statistics?.totalCost == 0){
        console.log("Graph creation status: No response")
      } else {
        console.log("Graph creation status:", result.response.status?.message)
      }
      
      await new Promise((resolve) => setTimeout(resolve, 3000));
      
      console.log("----- Creates the graph again -----")
      
      const result_1 = await conn.createGraphIfNotExist(graph)
      
      console.log("Does the graph already exist?", result_1.exist)
      if(result_1.response.statistics?.totalCost == 0){
        console.log("Graph creation status: No response")
      } else {
        console.log("Graph creation status:", result_1.response.status?.message)
      }
      

      Does the graph already exist? false
      Graph creation status: SUCCESS
      ----- Creates the graph again -----
      Does the graph already exist? true
      Graph creation status: No response
      

      alterGraph()

      Alters the name and description of a graph in the database.

      Parameters

      • graphName: string: Name of the graph.
      • alterGraphset: GraphSet: A GraphSet object used to set the new name and/or description for the graph.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • Response: Response of the request.

      // Alters the name and description of the graph 'testNodeJSSDK'
      
      const newGraphInfo: GraphSet = {
        name: "newGraph",
        description: "a new graph",
      };
      const response = await conn.alterGraph("testNodejsSDK", newGraphInfo);
      console.log(response.status?.message);
      

      SUCCESS
      

      dropGraph()

      Deletes a specified graph from the database.

      Parameters

      • graphName: string: Name of the graph.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • Response: Reponse of the request.

      // Drops the graph 'testNodeJSSDK'
      
      const response = await conn.dropGraph("testNodejsSDK");
      console.log(response.status?.message);
      

      SUCCESS
      

      truncate()

      Truncates (Deletes) the specified nodes or edges in a graph or truncates the entire graph. Note that truncating nodes will cause the deletion of edges attached to those affected nodes. The truncating operation retains the definition of schemas and properties in the graph.

      Parameters

      • params: TruncateParams: The truncate parameters; the attribute graphName is mandatory, schemaName and dbType are optional.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • Response: Response of the request.

      // Truncates User nodes in 'myGraph'
      
      const param1:TruncateParams = {graphName:"myGraph",schemaName:"User",dbType:DBType.DBNODE}
      const response1 = await conn.truncate(param1);
      console.log(response1.status?.message);
      
      // Truncates all edges in the 'myGraph'
      
      const param2:TruncateParams = {graphName:"myGraph",schemaName:"*",dbType:DBType.DBEDGE}
      const response2 = await conn.truncate(param2);
      console.log(response2.status?.message);
      
      // Truncates 'myGraph'
      
      const param3:TruncateParams = {graphName:"myGraph"}
      const response3 = await conn.truncate(param3);
      console.log(response3.status?.message);
      

      SUCCESS
      SUCCESS
      SUCCESS
      

      compact()

      Clears invalid and redundant data for a graph. Valid data will not be affected.

      Parameters

      • graphName: string: Name of the graph.
      • config: RequestConfig (Optional): Request configuration.

      Returns

      • JobResponse: Response of the request.

      // Compacts the graph 'miniCircle'
      
      const requestConfig: RequestConfig = { graph: "miniCircle" };
      const response = await conn.compact("miniCircle");
      const jobID = response.jobId;
      
      await new Promise(resolve => setTimeout(resolve, 2000))
      
      const jobs = await conn.showJob(jobID, requestConfig);
      for (const job of jobs) {
        console.log(`${job.id} - ${job.status}`);
      }
      

      29 - FINISHED
      29_1 - FINISHED
      29_2 - FINISHED
      29_3 - FINISHED
      

      Full Example

      import { ConnectionPool } from "@ultipa-graph/ultipa-driver";
      import { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types";
      import { GraphSet } from "@ultipa-graph/ultipa-driver/dist/types/types";
      
      let sdkUsage = async () => {
        // URI example: ultipaConfig.hosts: ["mqj4zouys.us-east-1.cloud.ultipa.com:60010"]
        const ultipaConfig: ULTIPA.UltipaConfig = {
          hosts: ["192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"],
          username: "<username>",
          password: "<password>"
        };
      
        const conn = await new ConnectionPool(
          ultipaConfig.hosts,
          ultipaConfig.username,
          ultipaConfig.password
        ).getActive();
        const isSuccess = await conn.test();
        console.log(`Connection succeeds: ${isSuccess}`);
      
        // Creates a graph
      
        const graph: GraphSet = {
          name: "testNodejsSDK",
          shards: ["1"],
          partitionBy: "Crc32",
          description: "testNodejsSDK desc",
        };
        const response = await conn.createGraph(graph);
        console.log(response.status?.message);
      };
      
      sdkUsage().catch(console.error);
      
      Please complete the following information to download this book
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写