aliyun-tablestore-nodejs-sdk
Version:
TableStore SDK for JavaScript
30 lines (26 loc) • 1.01 kB
JavaScript
var TableStore = require('../index.js');
var Long = TableStore.Long;
var client = require('./client');
var currentTimeStamp = Date.now();
var params = {
tableName: "sampleTable",
//不管此行是否已经存在,都会插入新数据,如果之前有会被覆盖。condition的详细使用说明,请参考conditionUpdateRow.js
condition: new TableStore.Condition(TableStore.RowExistenceExpectation.IGNORE, null),
primaryKey: [{ 'gid': Long.fromNumber(20013) }, { 'uid': Long.fromNumber(20013) }],
attributeColumns: [
{ 'col1': '表格存储' },
//客户端可以自己指定版本号(时间戳)
{ 'col2': '2', 'timestamp': currentTimeStamp },
{ 'col3': 3.1 },
{ 'col4': -0.32 },
{ 'col5': Long.fromNumber(123456789) }
],
returnContent: { returnType: TableStore.ReturnType.Primarykey }
};
client.putRow(params, function (err, data) {
if (err) {
console.log('error:', err);
return;
}
console.log('success:', data);
});