Giter Site home page Giter Site logo

ots's Introduction

OTS SDK Build Status Coverage Status

This project no longer maintained, please use https://github.com/ali-sdk/ots2 instead.

NPM

Aliyun OTS(Open Table Service) SDK for Node.js.

Using protobuf protocol API on [email protected]+.

WANNING If you are still using XML protocol API, please use ots<=0.3.0.

Support API

  • TableGroup
    • CreateTableGroup
    • DeleteTableGroup
    • ListTableGroup
  • Table
    • CreateTable
    • DeleteTable
    • GetTableMeta
    • ListTable
  • Transaction
    • StartTransaction
    • CommitTransaction
    • AbortTransaction
  • DataRow
    • PutRow
    • MultiPutRow (Max 100 rows)
    • DeleteRow
    • MultiDeleteRow (Max 100 rows)
    • BatchModifyRow (working)
    • GetRow
    • MultiGetRow (Max 10 rows)
    • GetRowsByRange
    • GetRowsByOffset (removed)

Install

$ npm install ots

# If you are still using XML protocol API, please use this:
$ npm install [email protected]

Usage

var ots = require('ots');
var client = ots.createClient({
  accessID: 'your accessID',
  accessKey: 'your accessKey'
});

// create a table
client.createTable({
  TableName: 'testdemo',
  PrimaryKey: [
    {'Name': 'uid', 'Type': 'STRING'},
  ],
  PagingKeyLen: 0,
  View: [
    {
      'Name': 'view1',
      'PrimaryKey' : [
        {'Name':'uid', 'Type':'STRING'},
        {'Name':'flag', 'Type':'STRING'},
        {'Name':'docid', 'Type':'STRING'},
      ],
      'Column' : [
        {'Name':'updatetime', 'Type':'STRING'},
        {'Name':'createtime', 'Type':'STRING'},
      ],
     'PagingKeyLen': 2
    }
  ]
}, function(err, result) {
  console.log(err, result);
});

// insert a row
client.putRow('user',
  { Name: 'uid', Value: 'mk2' },
  [
    { Name: 'firstname', Value: 'yuan' },
    { Name: 'lastname', Value: 'feng\' aerdeng' },
    { Name: 'nickname', Value: '苏千' },
    { Name: 'age', Value: 28 },
    { Name: 'price', Value: 110.5 },
    { Name: 'enable', Value: true },
    { Name: 'man', Value: true },
    { Name: 'female', Value: false },
    { Name: 'createtime', Value: new Date().toJSON() },
  ], function(err, result) {
  console.log(err, result);
});

// get a row
client.getRow('user', { Name: 'uid', Value: 'mk2' }, function (err, row) {
  console.log(err, row);
});

More examples, please see test/client.test.js.

Links

Authors

$ git summary

 project  : ots
 repo age : 1 year, 7 months
 active   : 22 days
 commits  : 63
 files    : 23
 authors  :
    58  fengmk2                 92.1%
     3  tangyao                 4.8%
     2  coolme200               3.2%

License

(The MIT License)

Copyright (c) 2012 - 2013 fengmk2 <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ots's People

Contributors

fengmk2 avatar coolme200 avatar jacksontian avatar edwardliwang avatar

Stargazers

 avatar Felipe Monteiro avatar 杰飒影视 avatar 天马行空 avatar  avatar  avatar  avatar Young Chen avatar  avatar  avatar Miller avatar 阳自然 avatar pinjer avatar  avatar Suriyaa Sundararuban avatar 米豆 avatar Zhipeng Jiang avatar  avatar Zoouya avatar  avatar Shangbin Yang avatar  avatar RaisCui avatar tom zhou avatar  avatar alsotang avatar jim avatar OSdio avatar  avatar Zan Pan avatar Bright Chen avatar toby avatar XS avatar achun avatar Yingnan Song avatar zhou avatar  avatar 橘子 avatar loseheaven avatar 孟维 avatar fantasyni avatar wanli avatar LEI Zongmin avatar Guan Bo avatar  avatar winglechen avatar clark avatar  avatar

Watchers

 avatar  avatar Longda avatar James Cloos avatar Dai Wenzhuo avatar fisher avatar Yiyu He avatar luics avatar 家娃 avatar  avatar 李振宇 avatar  avatar yemol yuan avatar 米豆 avatar Liu, Longbin avatar  avatar  avatar

ots's Issues

这个项目还维护吗,报了很多错误啊!

windows 7 x64
node v: 7.1.0

D:\Node\bigData\node_modules\nan\nan.h(318): error C2039: 'New': is not a member of 'v8::String' (compiling source file ..\node-expat.cc) [D:\Node\bigData\node_modules\node-expat\build\node_expat.vcxproj]
  c:\users\admin\.node-gyp\7.1.0\include\node\v8.h(2093): note: see declaration of 'v8::String' (compiling source file ..\node-expat.cc)
D:\Node\bigData\node_modules\nan\nan.h(318): error C3861: 'New': identifier not found (compiling source file ..\node-expat.cc) [D:\Node\bigData\node_modules\node-expat\build\node_expat.vcxproj]
D:\Node\bigData\node_modules\nan\nan.h(322): error C2039: 'ThrowException': is not a member of 'v8' (compiling source file ..\node-expat.cc) [D:\Node\bigData\node_modules\node-expat\build\node_expat.vcxproj]
  c:\users\admin\.node-gyp\7.1.0\include\node\v8.h(69): note: see declaration of 'v8' (compiling source file ..\node-expat.cc)
...

Error: Malformed message (uncaughtException throw 2 times on pid:216864)

image

2013-10-15 16:06:22.383 nodejs.ErrorException: Error: Malformed message (uncaughtException throw 2 times on pid:216864)
    at Function.parse (unknown source)
    at Client.request (/home/admin/datapi/target/datapi/node_modules/tcifapi/node_modules/ots/lib/client.js:990:30)
    at exports.request.done (/home/admin/datapi/target/datapi/node_modules/urllib/lib/urllib.js:196:5)
    at IncomingMessage.exports.request.timeout (/home/admin/datapi/target/datapi/node_modules/urllib/lib/urllib.js:310:7)
    at IncomingMessage.EventEmitter.emit (events.js:126:20)
    at IncomingMessage._emitEnd (http.js:366:10)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
    at Socket.socketOnData [as ondata] (http.js:1367:20)
    at TCP.onread (net.js:403:27)
pid: 216864
domainThrown: false
Host: datapi057085.pre.cm3
URL: 
Data: ""
2013-10-15 16:06:22.383

support node 0.10

> [email protected] install /Users/mk2/git/ots/node_modules/xml2json-edp/node_modules/node-expat
> node-waf configure build

sh: node-waf: command not found
npm ERR! [email protected] install: `node-waf configure build`
npm ERR! `sh "-c" "node-waf configure build"` failed with 127
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

protocol/ots_protocol.proto

package com.aliyun.cloudservice.ots;

/* common structure */
enum ColumnType {
    INF_MIN = 0;
    INF_MAX = 1;
    INTEGER = 2;
    STRING = 3;
    BOOLEAN = 4;
    DOUBLE = 5;
}

message ColumnSchema {
    required string name = 1;
    required ColumnType type = 2;
}

message ColumnValue {
    required ColumnType type = 1;
    optional int64 value_i = 2;
    optional string value_s = 3;
    optional bool value_b = 4;
    optional double value_d = 5;
}

message Column {
    required string name = 1;
    required ColumnValue value = 2;
}

message Row {
    repeated Column primary_keys = 1;
    repeated Column columns = 2;
}

message RowPutChange {
    enum CheckingType {
        NO = 0;
        UPDATE = 1;
        INSERT = 2;
    }

    required Row row = 1;
    required CheckingType checking_type = 2 [default = NO];
}

message RowDeleteChange {
    repeated Column primary_keys = 1;
    repeated string column_names = 2;
}

message ViewMeta {
    required string view_name = 1;
    repeated ColumnSchema primary_keys = 2;
    repeated ColumnSchema columns = 3;
}

message TableMeta {
    required string table_name = 1;
    repeated ViewMeta views = 2;
    repeated ColumnSchema primary_keys = 3;
    optional string table_group_name = 4;
}

message GetRowParameter {
    required string table_name = 1;
    repeated Column primary_keys = 2;
    repeated string column_names = 3;
}

message PutRowParameter {
    required string table_name = 1;
    required RowPutChange row_change = 2;
}

message DeleteRowParameter {
    required string table_name = 1;
    required RowDeleteChange row_change = 2;
}

message ErrorMessage {
    required string code = 1;
    optional string message = 2;
}

/* CreateTableGroup */
message CreateTableGroupRequest {
    required string table_group_name = 1;
    required ColumnType partition_key_type = 2;
}

// no response message

/* DeleteTableGroup */
message DeleteTableGroupRequest {
    required string table_group_name = 1;
}

// no response message

/* ListTableGroup */
// no request message

message ListTableGroupResponse {
    repeated string table_group_names = 1;
}

/* CreateTable */
message CreateTableRequest {
    required TableMeta table_meta = 1;
}

// no response message

/* ListTable */
// no request message

message ListTableResponse {
    repeated string table_names = 1;
}

/* GetTableMeta */
message GetTableMetaRequest {
    required string table_name = 1;
}

message GetTableMetaResponse {
    required TableMeta table_meta = 1;
}

/* DeleteTable */
message DeleteTableRequest {
    required string table_name = 1;
}

// no response message

/* StartTransaction */
message StartTransactionRequest {
    required string entity_name = 1;
    required ColumnValue partition_key_value = 2;
}

message StartTransactionResponse {
    required string transaction_id = 1;
}

/* AbortTransaction */
message AbortTransactionRequest {
    required string transaction_id = 1;
}

// no response message

/* CommitTransaction */
message CommitTransactionRequest {
    required string transaction_id = 1;
}

// no response message

/* GetRow */
message GetRowRequest {
    required GetRowParameter get_row_parameter = 1;
    optional string transaction_id = 2;
}

message GetRowResponse {
    required string table_name = 1;
    required Row row = 2;
}

/* GetRowsByRange */
message GetRowsByRangeRequest {
    required string table_name= 1;
    repeated Column primary_key_prefix = 2;
    required string range_key_name = 3;
    required ColumnValue range_begin = 4;
    required ColumnValue range_end = 5;
    repeated string column_names = 6;
    required bool is_reverse = 7 [default = false];
    optional uint32 limit = 8;
    optional string next_token = 9;
    optional string transaction_id = 10;
}

message GetRowsByRangeResponse {
    required string table_name = 1;
    repeated Row rows = 2;
    optional string next_token = 3;
}

/* PutRow */
message PutRowRequest {
    required PutRowParameter put_row_parameter = 1;
    optional string transaction_id = 2;
}

// no response message

/* DeleteRow */
message DeleteRowRequest {
    required DeleteRowParameter delete_row_parameter = 1;
    optional string transaction_id = 2;
}

// no response message

/* BatchModifyRow */
message ModifyItem {
    enum ModifyType {
        PUT = 0;
        DELETE = 1;
    }

    required ModifyType type = 1;
    optional RowPutChange row_put_change = 2;
    optional RowDeleteChange row_delete_change = 3;
}

message BatchModifyRowRequest {
    required string table_name = 1;
    repeated ModifyItem modify_items = 2;
    required string transaction_id = 3;
}

// no response message

/* MultiGetRow */
message MultiGetRowRequest {
    repeated GetRowParameter parameters = 1;
}

message MultiGetRowResponseItem {
     required bool is_succeed = 1;
     optional ErrorMessage error = 2;
     optional string table_name = 3;
     optional Row row = 4;
}

message MultiGetRowResponse {
     repeated MultiGetRowResponseItem items = 1;
}

/* MultiPutRow */
message MultiPutRowRequest {
    repeated PutRowParameter parameters = 1;
}

message MultiPutRowResponse {
    repeated ErrorMessage messages = 1;
}

/* MultiDeleteRow */
message MultiDeleteRowRequest {
    repeated DeleteRowParameter parameters = 1;
}

message MultiDeleteRowResponse {
    repeated ErrorMessage messages = 1;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.