I have the following dataset in my rethinkdb Database. I want to calculate the sum of one attribute named Min. I want to sum the all values of Min.
For example with the following dataset the query should return 8
{
"completedAt": Fri Dec 30 2016 10:05:17 GMT+00:00 ,
"Min": 0 ,
}
{
"completedAt": Fri Dec 30 2016 10:05:17 GMT+00:00 ,
"Min": 3 ,
}
{
"completedAt": Fri Dec 30 2016 10:05:17 GMT+00:00 ,
"Min": 5 ,
}
Can you help?
For sum:
You got error:
with
r.db('dbone').table("usertable").filter(r.row("userid").eq("002") ).pluck('Min').sum()
cause afterpluck
you get array of objects. To makesum
on result ofpluck
you should get field like this:or pass field name to
sum
: