RethinkDB:​​如何按字符串字段的长度排序?

Cha*_*non 2 rethinkdb

假设我有一个带有标题字段的文章表.我怎么能得到一个文章列表,按照他们的标题多长时间排序?

恩.文章:

{id: '101', title: 'A title', contents: 'Lots of text'}
Run Code Online (Sandbox Code Playgroud)

我试过了:

r.table('story').orderBy(function(doc){return r.row('title').length}).pluck('title')
Run Code Online (Sandbox Code Playgroud)

但这是错的.

neu*_*ino 5

split("").count()现在可以使用它作为工作

r.table("story").orderBy(function(doc) {
    return doc("title").split("").count()
}).pluck("title")
Run Code Online (Sandbox Code Playgroud)

请参阅https://github.com/rethinkdb/rethinkdb/issues/264以跟踪本机方法的进度以获取字符串的长度.