修改密码

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

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
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

      连接

      完成安装嬴图Node.js SDK,设置一个运行的嬴图实例后,可以开始将您的应用连接到嬴图数据库。

      ConnectionPool

      可以使用ConnectionPool指定所需的连接池信息,从而建立与嬴图数据库的连接。

      以下是ConnectionPool的所有可用配置项:

      项目
      类型
      描述
      hosts string[] 数据库主机地址或主机URI(不包括https://http://)。使用逗号分隔多个实例地址。必需项
      username string 主机验证用户名。必需项
      password string 主机验证密码。必需项
      crt Buffer 设置本地证书文件路径。连接时将使用SSL
      defaultConfig ULTIPA.UltipaConfig 其他配置,包括图集设置、超时设置和一致性设置
      otherParams object 包含两个键:isHttpsisHttp,均为布尔值类型。如果两者均设置为true,优先使用HTTP。若未指定,连接将优先尝试HTTP,若HTTP连接失败,则切换到HTTPS

      连接到集群

      以下示例展示如何连接到集群并使用图集default。

      import { ConnectionPool } from "@ultipa-graph/ultipa-node-sdk";
      import fs from "fs";
      
      let sdkUsage = async () => {
      
        let hosts = [
          "192.168.1.85:60061", 
          "192.168.1.86:60061", 
          "192.168.1.87:60061"
        ];
        let username = "***";
        let password = "***";
        let crt: Buffer;
        { // 使用证书(Crt)
          let crt_file_path = "./ultipa.crt";
          crt = fs.readFileSync(crt_file_path);
        }
        let connPool = new ConnectionPool(hosts, username, password, crt);
        
        let conn = await connPool.getActive();
        let isSuccess = await conn.test();
        console.log(isSuccess);
      };
      
      sdkUsage().then(console.log).catch(console.log);
      

      连接到嬴图Cloud

      以下示例展示如何连接到嬴图Cloud实例并使用图集default。

      import { ConnectionPool } from "@ultipa-graph/ultipa-node-sdk";
      
      let sdkUsage = async () => {
      
        let hosts = ["3xbotdjas.us-east-1.cloud.ultipa.com:60010"];
        let username = "***";
        let password = "***";
        let otherParams = {
          isHttps: true,
          isHttp: false
        };
        let connPool = new ConnectionPool(hosts, username, password, undefined, undefined, otherParams);
        
        let conn = await connPool.getActive();
        let isSuccess = await conn.test();
        console.log(isSuccess);
      };
      
      sdkUsage().then(console.log).catch(console.log);
      

      配置项

      以下是UltipaConfig的所有可用配置项:

      项目
      类型
      描述
      graphSetName string 待使用的图集名称。若未设置,则使用建立连接时配置的graphSetName
      timeout number 请求超时阈值,单位为秒
      consistency boolean 是否使用主节点以确保一致性读取
      useHost string 发送请求到指定主机节点,若未设置则随机选择主机节点
      clusterID string 指定待使用的集群
      timeZone string 待使用的时区
      timeZoneOffset number 所用时区与UTC的时间差,单位为分钟
      timestampToString boolean 是否将时间戳转换为字符串
      logUql boolean 是否打印UQL
      threadNum number 线程数
      responseWithRequestInfo boolean 是否在响应中包含请求信息

      测试连接

      使用Connection对象的test()方法可以检查连接。

      let resp = await conn.test();
      console.log(resp);
      

      true
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写