修改密码

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

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Blaze (v4)
  • Ultipa Powerhouse (v5)

Standalone

点击

了解 Ultipa Powerhouse (v5)架构中的四大组成部分。

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.2
搜索
    v5.2

      快速开始

      嬴图的Node.js驱动是一个JavaScript库,让用户可以在任何Node.js环境中与嬴图数据库进行交互。它支持Node.js v12.22.12或更高版本

      安装驱动

      npm官方源获取并安装最新版嬴图包:

      npm install @ultipa-graph/ultipa-driver
      

      连接数据库

      为了使用驱动,需要有一个处于活跃状态的嬴图数据库。创建一个数据库实例最简单的方法是通过嬴图Cloud(提供免费试用)。当然也可以使用私有部署的嬴图数据库。

      连接数据库并测试连接是否成功:

      import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
      import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js";
      
      let sdkUsage = async () => {
        const ultipaConfig: ULTIPA.UltipaConfig = {
          // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"]
          hosts: ["10.xx.xx.xx:60010"],
          username: "<username>",
          password: "<password>"
        };
      
        const driver = new UltipaDriver(ultipaConfig);
        
        // Tests the connection
        const isSuccess = await driver.test();
        console.log(`Connection succeeds: ${isSuccess}`);
      };
      
      sdkUsage().catch(console.error);
      

      Connection succeeds: true
      

      查看关于数据库连接的更多信息 →

      查询数据库

      GQL是国际标准化的图数据库查询语言。你可以使用驱动的gql()方法发送GQL语句来全方位操作数据库。如果还不熟悉GQL,可以阅读GQL快速入门,或者更详细的GQL文档

      查看关于数据库查询的更多信息 →

      创建一个图

      在数据库中新建一个图:

      import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
      import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js";
      
      let sdkUsage = async () => {
        const ultipaConfig: ULTIPA.UltipaConfig = {
          // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"]
          hosts: ["10.xx.xx.xx:60010"],
          username: "<username>",
          password: "<password>"
        };
      
        const driver = new UltipaDriver(ultipaConfig);
        
        // Creates a new open graph named 'g1'
        let response = await driver.gql("CREATE GRAPH g1 ANY")
        console.log(response.status?.message)
      };
      
      sdkUsage().catch(console.error);
      

      SUCCESS
      

      插入点和边

      向图中插入点和边:

      import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
      import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js";
      
      async function sdkUsage() {
        const ultipaConfig: ULTIPA.UltipaConfig = {
          // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"]
          hosts: ["10.xx.xx.xx:60010"],
          username: "<username>",
          password: "<password>",
          defaultGraph: "g1" // Sets the default graph to 'g1'
        };
      
        const driver = new UltipaDriver(ultipaConfig);
      
        // Inserts nodes and edges into graph the 'g1'
        let response = await driver.gql(`INSERT 
          (u1:User {_id: 'U1', name: 'rowlock'}),
          (u2:User {_id: 'U2', name: 'Brainy'}),
          (u3:User {_id: 'U3', name: 'purplechalk'}),
          (u4:User {_id: 'U4', name: 'mochaeach'}),
          (u5:User {_id: 'U5', name: 'lionbower'}),
          (u1)-[:Follows {createdOn: DATE('2024-01-05')}]->(u2),
          (u4)-[:Follows {createdOn: DATE('2024-02-10')}]->(u2),
          (u2)-[:Follows {createdOn: DATE('2024-02-01')}]->(u3),
          (u3)-[:Follows {createdOn: DATE('2024-05-03')}]->(u5)`);
        console.log(response.status?.message);
      }
      
      sdkUsage().catch(console.error);
      

      SUCCESS
      

      查询点

      在图中查询点:

      import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
      import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js";
      import { RequestConfig } from "@ultipa-graph/ultipa-driver/dist/types/types.js";
      
      let sdkUsage = async () => {
        const ultipaConfig: ULTIPA.UltipaConfig = {
          // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"]
          hosts: ["10.xx.xx.xx:60010"],
          username: "<username>",
          password: "<password>",
          defaultGraph: "amz" // Optional; sets the default graph as 'amz'
        };
      
        const driver = new UltipaDriver(ultipaConfig);
        
        // Retrieves 3 User nodes from the graph 'g1'
        const requestConfig: RequestConfig = {
          graph: "g1" // Sets the graph for the specific request as 'g1'
        }; 
        let response = await driver.gql("MATCH (u:User) RETURN u LIMIT 3", requestConfig);
        const nodes = response.alias("u").asNodes();
        for (const node of nodes) {
          console.log(node)
        };
      };
      
      sdkUsage().catch(console.error);
      

      Node {
        uuid: '6557243256474697731',
        id: 'U4',
        schema: 'User',
        values: { name: 'mochaeach', gender: "male" }
      }
      Node {
        uuid: '7926337543195328514',
        id: 'U2',
        schema: 'User',
        values: { name: 'Brainy', gender: "female"  }
      }
      Node {
        uuid: '14771808976798482436',
        id: 'U5',
        schema: 'User',
        values: { name: 'lionbower', gender: "male"  }
      }
      

      处理查询结果

      驱动的gql()方法返回的Response包含数据库返回的原始查询结果和执行信息。为了在应用中使用查询结果,你需要将其提取出来并转换成可用的数据结构。

      上面的点查询示例中,使用alias()方法提取查询结果,再使用asNodes()方法将其转换为一个Node列表:

      // Retrieves 3 User nodes from the graph 'g1'
      const requestConfig: RequestConfig = {
        graph: "g1" // Sets the graph for the specific request as 'g1'
      }; 
      let response = await driver.gql("MATCH (u:User) RETURN u LIMIT 3", requestConfig);
      const nodes = response.alias("u").asNodes();
      for (const node of nodes) {
        console.log(node)
      };
      

      使用何种转换方法取决于查询结果的类型,比如点、边、路径、属性值等。用户可在此查看所有的转换方法和示例。

      便捷方法

      除了用于执行自定义GQL语句的gql()方法之外,驱动还提供了一系列便捷方法,以简化常见的数据库操作。这些方法让用户轻松执行以下类别的任务,无需编写完整的查询语句:

      • :在数据库中获取、创建、修改或删除图。
      • Schema和属性:定义和修改图中点和边的Schema以及属性。
      • 数据插入:高效地向图中插图点和边。
      • 查询加速:管理用于提高查询效率的索引和全文索引。
      • HDC图和算法:管理HDC图并运行算法。
      • 进程与作业:监控正在运行的进程,管理后台作业。
      • 访问控制:配置用户权限和策略(角色)。
      • 数据导出:导出图中的点和边。

      例如,showGraph()方法获取数据库中所有的图,它返回一个GraphSet列表:

      import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
      import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js";
      
      let sdkUsage = async () => {
        const ultipaConfig: ULTIPA.UltipaConfig = {
          // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"]
          hosts: ["10.xx.xx.xx:60010"],
          username: "<username>",
          password: "<password>"
        };
      
        const driver = new UltipaDriver(ultipaConfig);
        
        // Retrieves all graphs in the database
        const graphs = await driver.showGraph();
        for (const graph of graphs) {
          console.log(graph.name)
        }
      };
      
      sdkUsage().catch(console.error);
      

      g1
      miniCircle
      amz
      

      例如,insertNodes()方法向图中插入点,用户只需提供目标Schema名称以及一个Node列表:

      import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
      import type { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types/index.js";
      import { InsertRequestConfig } from "@ultipa-graph/ultipa-driver/dist/types/types.js";
      
      let sdkUsage = async () => {
        const ultipaConfig: ULTIPA.UltipaConfig = {
          // URI example: hosts: ["xxxx.us-east-1.cloud.ultipa.com:60010"]
          hosts: ["10.xx.xx.xx:60010"],
          username: "<username>",
          password: "<password>"
        };
      
        const driver = new UltipaDriver(ultipaConfig);
        
        // Inserts two User nodes into the graph 'g1'
      
        const insertRequestConfig: InsertRequestConfig = { graph: "g1" };
      
        const node1 = {
          id: "U6",
          values: {
            name: "Alice",
            age: 28
          },
        };
        const node2 = {
          id: "U7",
          values: {
            name: "Quars"
          },
        };
        const nodes = [node1, node2]
      
        let response = await driver.insertNodes("User", nodes, insertRequestConfig);
        console.log(response.status?.message);
      };
      
      sdkUsage().catch(console.error);
      

      SUCCESS
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写
      隐私政策
      请勾选表示您已阅读并同意。

      Copyright © 2019-2025 北京同心尚科技发展有限公司-保留所有权利 京ICP备19040872号-1