OTSWhere
使阿里云表格存储 OTS 的条件过滤与数据格式化变得更简单
Usage
$ npm i otswhere
where 条件过滤
const OTSWhere = ;const tbCondition = ; const params = tableName: 'test' direction: TableStoreDirectionBACKWARD inclusiveStartPrimaryKey: id: TableStoreINF_MAX exclusiveEndPrimaryKey: id: TableStoreIN_MIN columnFilter: tbCondition // where condition;
Operator
operator | comment |
---|---|
= | TableStore.ComparatorType.EQUAL |
!= | TableStore.ComparatorType.NOT_EQUAL |
> | TableStore.ComparatorType.GREATER_THAN |
>= | TableStore.ComparatorType.GREATER_EQUAL |
< | TableStore.ComparatorType.LESS_THAN |
<= | TableStore.ComparatorType.LESS_EQUAL |
& | TableStore.LogicalOperator.AND |
| | TableStore.LogicalOperator.OR |
数据格式化
将表格存储 getRange 与 getRow 返回的数据进行格式化,分别变为列表与对象:
const format = ; // for getRowconst row = format; console;// {// name: 'test row',// id: 123456,// age: 24,// address: 'HangZhou,China'// } // for getRangeconst rows = formatrows rows: primaryKey: name: 'name' value: '1' attributes: columnName: 'age' columnValue: 24 primaryKey: name: 'name' value: '2' attributes: columnName: 'age' columnValue: 23 next_start_primary_key: name: 'name' value: 3 ; console;// {// list: [// { name: '1', age: 24' },// { name: '2', age: 23 },// ],// next: {// name: 3// }// }
© MIT by echosoar