修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

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.

如果不需要 HDC 服务,则此项留空。

Please complete this required field.

如果不需要 HDC 服务,则此项留空。

Please complete this required field.

Please complete this required field.

所有服务器的MAC地址,由换行符或逗号分隔。

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
Shard 服务最大数量
Shard 服务最大总核数
HDC 服务最大数量
HDC 服务最大总核数
申请天数
审批日期
过期日期
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

v5.0
搜索
    v5.0

      本节介绍管理数据库中图的方法。

      showGraph()

      获取数据库中全部的图。

      参数

      • config: RequestConfig(可选):请求配置。

      返回值

      • GraphSet[]:获取的图列表。

      // 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()

      获取数据库中一个指定的图。

      参数

      • graphName: string:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • GraphSet:获取的图。

      // 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()

      检查数据库中是否存在一个指定的图。

      参数

      • graphName: string:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Boolean:检查结果。

      // 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()

      在数据库中创建一个图。

      参数

      • graphSet: GraphSet: The graph to be created; the attribute name is mandatory, shards, partitionBy and description are optional.
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      // 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()

      在数据库中创建一个图,并返回是否数据库中已有同名图存在。

      参数

      • graphSet: GraphSet:待创建的图;name属性必填,shardspartitionBydescription可选。
      • config: RequestConfig(可选):请求配置。

      返回值

      • ResponseWithExistCheck:请求结果。

      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()

      修改数据库中一个图的名称和描述。

      参数

      • graphName: string:图名称。
      • alterGraphset: GraphSet: 用于设置新的图name和/或descriptionGraphSet对象。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      // 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()

      从数据库中删除一个指定的图。

      参数

      • graphName: string:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

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

      SUCCESS
      

      truncate()

      清空(删除)图中的指定点或边,或清空整个图。请注意,清空点的同时会删除与点相连的所有边。清空操作仅删除点边,图的schema和属性定义仍保留。

      参数

      • params: TruncateParams:清空操作的参数;graphName属性必填,schemaNamedbType可选。
      • config: RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。

      // 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()

      清除图中的无效及冗余数据。有效数据不会受到影响。

      参数

      • graphName: string:图名称。
      • config: RequestConfig(可选):请求配置。

      返回值

      • JobResponse:请求结果。

      // 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
      

      完整示例

      import { UltipaDriver } 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 = new UltipaDriver(ultipaConfig);
        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);
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写