Aliyun OTS client for Node.js(ES6)
Aliyun OTS数据库服务Node.js客户端。
OTS介绍
OTS是构建在阿里云飞天分布式系统之上的NoSQL数据库服务,提供海量结构化数据的存储和实时访问。OTS以实例和表的形式组织数据,通过数据分片和负载均衡技术,达到规模的无缝扩展。OTS向应用程序屏蔽底层硬件平台的故障和错误,能自动从各类错误中快速恢复,提供非常高的服务可用性。OTS管理的数据全部存储在SSD中并具有多个备份,提供了快速的访问性能和极高的数据可靠性。用户在使用OTS服务时,只需要按照预留和使用的资源进行付费,无需关心数据库的软硬件升级维护、集群缩容扩容等复杂问题。
更多细节请参见:https://help.aliyun.com/product/27278.html
安装
$ npm install ots2 --save
使用
创建客户端
var ots = ;var client = ots;
调用API
详细API文档请参见:http://doxmate.cool/ali-sdk/ots2/index.html
所有表的操作
// 列出所有表名 client;// 创建表var keys = 'name': 'uid' 'type': 'STRING' ;var capacityUnit = read: 1 write: 1;var response = client;// 更新表var capacityUnit = read: 2 write: 1;var response = client;// 查看表信息var response = client;// 删除表var response = client;
所有行的操作
// 写入行var name = 'metrics';var condition = row_existence: otsRowExistenceExpectationIGNORE;var primaryKeys = uid: 'test_uid'; var columns = test: 'test_value'; var response = client; // 读取行var name = 'metrics';var primaryKeys = uid: 'test_uid'; var columns = 'test';var response = client; // 更新行var name = 'metrics';var condition = row_existence: otsRowExistenceExpectationIGNORE;var primaryKeys = uid: 'test_uid'; var columns = test: ots; var response = client; // 删除行var name = 'metrics';var condition = row_existence: otsRowExistenceExpectationIGNORE;var primaryKeys = uid: 'test_uid'; var response = client;
批量操作
// 批量写var tables = table_name: 'metrics' put_rows: condition: row_existence: otsRowExistenceExpectationIGNORE primary_key: uid: 'test_uid' attribute_columns: test: 'test_value' update_rows: {} delete_rows: {} ;var response = client; // 批量读var tables = table_name: 'metrics' rows: primary_key: uid: 'test_uid' columns_to_get: 'test' ;var response = client; // 范围读var start = uid: otsInfMin; var end = uid: otsInfMax; var request = table_name: 'metrics' direction: otsDirectionFORWARD columns_to_get: 'test' limit: 4 inclusive_start_primary_key: start exclusive_end_primary_key: end;var response = client;
License
OTS服务由阿里云提供。但本模块在MIT许可下自由使用。
(The MIT license)