从 table 获取字段列表

Getting list of fields from a table

我知道此命令将为给定的 "document"

生成一个字段列表 ("keys")
r.table('users').get(1).keys()

我的问题:是否有一个命令可以为所有文档提供所有可能的唯一键名?

  1. keys.
  2. map吧。
  3. reduce吧。
  4. distinct 在结果数组上。

查询:

r.table('users').map(function(doc){
  return doc.keys();
}).reduce(function(uniq, doc){
  return uniq.setUnion(doc);
}).distinct()