Reputation: 5763
Docs:
[{
id: 111,
weight: 1
},{
id: 222,
},{
id: 333,
weight: -1
}]
I want to order the docs by weight
if weight
not exists treat its weight
as 0
How can I do that ?
Upvotes: 1
Views: 68
Reputation: 5672
You can use function as mentioned here with default:
r.table(TABLE_NAME).orderBy(r.asc(function(doc) {
return doc("weight").default(0)
}));
Upvotes: 3