npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@alicloud/ots2

v2.1.0

Published

OTS(2015-12-31) client for Node.js(ES6)

Readme

Aliyun OTS client for Node.js(ES6)

NPM version build status codecov

Aliyun OTS数据库服务Node.js客户端。

OTS介绍

OTS是构建在阿里云飞天分布式系统之上的NoSQL数据库服务,提供海量结构化数据的存储和实时访问。OTS以实例和表的形式组织数据,通过数据分片和负载均衡技术,达到规模的无缝扩展。OTS向应用程序屏蔽底层硬件平台的故障和错误,能自动从各类错误中快速恢复,提供非常高的服务可用性。OTS管理的数据全部存储在SSD中并具有多个备份,提供了快速的访问性能和极高的数据可靠性。用户在使用OTS服务时,只需要按照预留和使用的资源进行付费,无需关心数据库的软硬件升级维护、集群缩容扩容等复杂问题。

更多细节请参见:https://help.aliyun.com/product/27278.html

安装

$ npm install @alicloud/ots2 --save

使用

创建客户端

const ots = require('@alicloud/ots2');
var client = ots.createClient({
  accessKeyID: '<YOUR ACCESSKEYID>',
  accessKeySecret: '<YOUR ACCESSKEYSECRET>',
  instance: '<YOUR INSTANCE>',
  region: '<YOUR REGION>',
  keepAliveMsecs: 1000, // default 1000
  timeout: 3000 // default 3000ms
});

调用API

详细API文档请参见:http://doxmate.cool/ali-sdk/ots2/index.html

所有表的操作

// 列出所有表名
await client.listTable();
// 创建表
var keys = [{ 'name': 'uid', 'type': 'STRING' }];
// 若实例为‘容量型’,read 和 write 值必须为0,否则会报错 OTSParameterInvalidError: Can not reserve read capacity unit on capacity cluster
var capacityUnit = {read: 0, write: 0};
var options = {
  table_options: {
    time_to_live: -1,// 数据的过期时间, 单位秒, -1代表永不过期. 假如设置过期时间为一年, 即为 365 * 24 * 3600.
    max_versions: 1
  }
};
var response = await client.createTable('metrics', keys, capacityUnit, options);
// 更新表
var capacityUnit = {read: 2, write: 1};
var response = await client.updateTable('metrics', capacityUnit);
// 查看表信息
var response = await client.describeTable('metrics');
// 删除表
var response = await client.deleteTable('metrics');

所有行的操作

// 写入行
var name = 'metrics';
var condition = {
  row_existence: ots.RowExistenceExpectation.IGNORE
};
var primaryKeys = {uid: 'test_uid'};

var columns = {test: 'test_value'};

var response = await client.putRow(name, condition, primaryKeys, columns);

// 读取行
var name = 'metrics';
var primaryKeys = {uid: 'test_uid'};

var columns = ['test'];
var response = await client.getRow(name, primaryKeys, columns);

// 更新行
var name = 'metrics';
var condition = {
  row_existence: ots.RowExistenceExpectation.IGNORE
};
var primaryKeys = {uid: 'test_uid'};

var columns = {
  test: ots.$put('test_value_replaced')
};

var response = await client.updateRow(name, condition, primaryKeys, columns);

// 删除行
var name = 'metrics';
var condition = {
  row_existence: ots.RowExistenceExpectation.IGNORE
};
var primaryKeys = {
  uid: 'test_uid'
};

var response = await client.deleteRow(name, condition, primaryKeys);

批量操作

// 批量写
var tables = [
  {
    table_name: 'metrics',
    put_rows: [
      {
        condition: {
          row_existence: ots.RowExistenceExpectation.IGNORE
        },
        primary_key: {
          uid: 'test_uid'
        },
        attribute_columns: {
          test: 'test_value'
        }
      }
    ],
    update_rows: {},
    delete_rows: {}
  }
];
var response = await client.batchWriteRow(tables);

// 批量读
var tables = [
  {
    table_name: 'metrics',
    rows: [
      {
        primary_key: {
          uid: 'test_uid'
        }
      }
    ],
    columns_to_get: ['test']
  }
];
var response = await client.batchGetRow(tables);

// 范围读
var start = {
  uid: ots.InfMin
};

var end = {
  uid: ots.InfMax
};

var request = {
  table_name: 'metrics',
  direction: ots.Direction.FORWARD,
  columns_to_get: ['test'],
  limit: 4,
  inclusive_start_primary_key: start,
  exclusive_end_primary_key: end
};
var response = await client.getRange(request);

条件更新(Conditional Update)和过滤器(Filter)支持

条件更新和过滤器是一个 ConditionColumn 类型,是一种类似 SQL 中的 where 条件。

本模块提供一个makeFilter方法来快速生成一个 ConditionColumn 对象。

ots.makeFilter('column_name < @name true', {
  name: 'Jackson Tian'
});
// column_name => 表中的列名
// < => 操作符:==, !=, <, <=, >, >=
// @name 上下文中的属性名
// true => 列不存在时,默认结果

其中组合条件的语法(DSL)如下:

name == @name true
NOT name == @name true
NOT NOT name == @name true
name > @name true AND age <= @age false
name > @name true OR age <= @age false
NOT name > @name true AND age <= @age false
name > @name true AND age <= @age false AND gender == @gender true
name > @name true OR age <= @age false AND gender == @gender true

优先级顺序为:NOT > AND > OR

License

OTS服务由阿里云提供。但本模块在MIT许可下自由使用。

(The MIT license)