文档:
[{
id: 111,
weight: 1
},{
id: 222,
},{
id: 333,
weight: -1
}]
如果weight
不存在,我想按weight
订购文档将weight
视为0
我该怎么做?
答案 0 :(得分:3)
You can use function as mentioned here与default:
r.table(TABLE_NAME).orderBy(r.asc(function(doc) {
return doc("weight").default(0)
}));