1

我有以下数据结构格式:

unix/:/var/run/tarantool/tarantool.sock> s:format()
---
- [{'name': 'id', 'type': 'unsigned'}, {'name': 'version', 'type': 'array'}, {'name': 'data',
    'type': 'array'}]
...

我里面已经有以下数据:

unix/:/var/run/tarantool/tarantool.sock> s:select{}
---
- - [0, [[21, 'action123'], [12, 'actionXYZ'], [11, 'actionABC']], [['actionXYZ',
        'SOME_JAVASCRIPT_CONTENT']]]
  - [1, [[33, 'action123'], [12, 'baseXYZ'], [11, 'baseABC']], [['bas123', 'SOME_CSS_CONTENT']]]
...

我已阅读参考资料和文档,但在完成以下内容时有点迷失:

  1. 什么是“WHERE”等价物?IE。选择以查找具有 的version条目12

    在https://www.tarantool.io/en/doc/2.2/reference/reference_lua/box_space/#lua-function.space_object.select中没有看到适用的示例

  2. 列出带有字段名称的项目(所以我知道我在看什么块)。在某种程度上,有点像在 SQL 的结果中包含“列标题”。

    我在我的- 我在查询数据时如何查看这些名称format()

    {'name': 'id', 'type': 'unsigned'}, {'name': 'version', 'type': 'array'}, {'name': 'data', 'type': '大批'}]

  3. 漂亮的印刷品!(最好是yaml)

    我尝试使用https://www.tarantool.io/en/doc/2.2/reference/reference_lua/yaml/来环绕我的选择语句,但没有任何效果。

4

1 回答 1

0
  1. 您需要使用索引进行命令式有效查询,请看这里:

https://www.tarantool.io/en/doc/2.2/reference/reference_lua/box_space/#lua-function.space_object.create_index

https://www.tarantool.io/en/doc/2.2/reference/reference_lua/box_index/

  1. 使用元组:tomap():

https://www.tarantool.io/en/doc/2.2/reference/reference_lua/box_tuple/#lua-function.tuple_object.tomap

  1. 这取决于你想要它漂亮的地方。您可能需要调整 yaml 设置,或者简单地链接 tomap 调用:
tarantool> box.space.TEST:pairs():map(function(x) return x:tomap({names_only=true}) end):totable()
---
- - COLUMN1: 1
    COLUMN2: a
  - COLUMN1: 13
    COLUMN2: a
  - COLUMN1: 1000
    COLUMN2: a
于 2020-02-20T17:03:53.083 回答