按插入顺序检索文档

时间:2016-05-11 10:21:06

标签: rethinkdb

我想知道如何在rethinkdb中创建一个索引,它将按照添加顺序返回行,并将其用作一种日志。

1 个答案:

答案 0 :(得分:2)

您需要在文档中设置某种# Shorthand for table test = r.db("test").table("test") # Create index test.createIndex("datetime", r.row("datetime")) # Insert document with datetime field test.insert({ datetime: r.now(), }) # To get all documents in sorted order test.order_by(index="datetime") # To get documents after a certain point test.between(<some sort of datetime object>, r.maxval, index="datetime") 字段,如下所示:

$ul = <<<UL001
  <ul>
      <li>{$tabledata['id']}</li>
      <li>{$tabledata['email']}</li>
      <li>{$tabledata['first_name']} {$tabledata['last_name']}</li>
    </ul>
UL0001;

print $ul;