rethinkdb

How would you use map reduce on this document structure?

こ雲淡風輕ζ 提交于 2019-12-11 19:26:14
问题 If I wanted to count foobar.relationships.friend.count, how would I use map/reduce against this document structure so the count will equal 22. [ [0] { "rank" => nil, "profile_id" => 3, "20130913" => { "foobar" => { "relationships" => { "acquaintance" => { "count" => 0 }, "friend" => { "males_count" => 0, "ids" => [], "females_count" => 0, "count" => 10 } } } }, "20130912" => { "foobar" => { "relationships" => { "acquaintance" => { "count" => 0 }, "friend" => { "males_count" => 0, "ids" => [

How do I run a filter on a getNearest() query in RethinkDB?

孤街浪徒 提交于 2019-12-11 18:05:32
问题 I have a table with users and their locations saved as r.point datatypes & a geo index set on them. I am trying to run a .getNearest() query, which returns all the users closest to the given user (say, Mr. X ). The results return all the users closest to Mr. X , but also include Mr. X . How do I filter all users except Mr. X ? What I've tried so far — In RethinkDB's Data Explorer (Plain ReQL commands) r.db('myDb').table('myTable').getNearest(r.point(-20, 39), {index: 'location'}).filter

Socket.io changefeed multiple emits on refresh / reload

元气小坏坏 提交于 2019-12-11 15:26:50
问题 I'm having this exact problem: https://github.com/rethinkdb/rethinkdb/issues/6503 First time I connect, it console.logs 1 time. If I refresh it console.log 2 times. If I refresh again, it console logs 3 times. and so on.Keep adding one more console.log / run to each reload. The same with socket.emit. It keeps adding 1 extra on each reload. In the link above he describes how to fix it, with this code: options.socket.on('close', () => { conn.close({ noreplyWait: false }); }); I would love to

Rethink DB Cross Cluster Replication

岁酱吖の 提交于 2019-12-11 10:59:51
问题 I have 3 different pool of clients in 3 different geographical locations. I need configure Rethinkdb with 3 different clusters and replicate data between the (insert, update and deletes). I do not want to use shard, only replication. I didn't found in documentation if this is possible. I didn't found in documentation how to configure multi-cluster replication. Any help is appreciated. 回答1: I think that multi cluster is just same a single clusters with nodes in different data center First, you

Get size of Rethinkdb database with Python

笑着哭i 提交于 2019-12-11 09:44:07
问题 How do I get the size of a given rethinkdb database using Python? I want this because I'm developing a mutli-user graphical frontend to rethinkdb and want to be able to enforce a quota for each user's database. Something like below would be awesome: r.db('thedatabase').size().run() 50gb 回答1: RethinkDB doesn't have a built-in command for such operation. The easiest solution would be probably to spin up multiple RethinkDB instances on their own (limited) partition (using Docker would probably

How to update an item in a embedded list?

痞子三分冷 提交于 2019-12-11 09:26:43
问题 I have a josn named "update",and it has an embedded list "comments" like this: { id: "update/0", //comments contains elements with type:comment comments: [{ id:"comment/0" content:"old first level comment content..." children:[{ id:"comment/00", content:""old second level comment content...", children[...] } ] }] } Questions are: 1, How to replace "old first level comment content..." with "new first level comment content..." by ids "update/0" and "comment/0"? 2, How to replace "old second

How to update a nested object in rethinkDB

女生的网名这么多〃 提交于 2019-12-11 06:36:56
问题 I am getting an issue while updating a nested object.sample data like this { "status":{ "draft":{ "status":"draft", "rating":4 }, "review":{ "status":"review", "rating":4 }, "publish":{ "status":"publish", "rating":4 } } } In the above object some times the draft/ review/ publish are empty objects and need to check the condition and update the rating in the object.I have tried like this but getting error. query: r.db('sample_db').table('table').filter({id:'xxxxxxx'}) .update({"draft": r.row(

rethinkdb - hasFields to find all documents with multiple multiple missing conditions

邮差的信 提交于 2019-12-11 05:44:55
问题 I found an answer for finding all documents in a table with missing fields in this SO thread RethinkDB - Find documents with missing field, however I want to filter according to a missing field AND a certain value in a different field. I want to return all documents that are missing field email and whose isCurrent: value is 1 . So, I want to return all current clients who are missing the email field, so that I can add the field. The documentation on rethink's site does not cover this case.

RethinkDB: “TypeError: 'Var' object is not callable” when using lambda function in filter

百般思念 提交于 2019-12-11 02:46:14
问题 In RethinkDB's data explorer, I'm running this query successfully using javascript: r.db('my_db').table('my_table').filter(function(row){return row('some_key').match(".sometext.")}) But when I'm running it correspondingly in python like this: r.db('my_db').table('my_table').filter(lambda row: row('some_key').match(".sometext.")) I'm getting the following error: TypeError: 'Var' object is not callable In [16]: rql = r.db('my_db').table('my_table').filter(lambda row: row('some_key').match("

RethinkDB: multiple comparisons filtering

流过昼夜 提交于 2019-12-11 02:44:50
问题 By the docs, it seems that in order to filter all users that are 30 years old OR 40 years old, I can do this (with python): r.table("users").filter((r.row["age"].eq(30)) | (r.row["age"].eq(40))).run(conn) Say I have a list based on input / request: [12, 14, 18, 88, 33 ...], how do I filter all the users that are in the age of one of the elements in the list above by iterating it (and not doing it hard coded)? 回答1: That's one way to do it valid_ages = [12, 14, 18, 88, 33] r.table("users")