rethinkdb

How to stop a goroutine that is listening for RethinkDB changefeeds?

时光毁灭记忆、已成空白 提交于 2019-12-10 22:22:08
问题 I am trying to figure out how to use RethinkDB changefeeds with golang. My specific question is how to stop a goroutine that listens for changes to the database. See, for example, the function getData() below. I run this from a handler function by calling go getData(c) . Whenever the database updates, the record is passed to the channel c , which is then passed to the handler function and sent to the client using SSE technology. My question is: when the client disconnects, I know how to stop

Find nested array-object from rethinkdb in feathers JS

北城以北 提交于 2019-12-10 16:56:42
问题 I have a data set like follows- [{ "allowedusers": ["paul@abc.com"], "id": "1" },{ "allowedusers": ["kmahera@abc.com","rbajaniya@abc.com"], "id": "2" },{ "allowedusers": ["whatever@abc.com","rbajaniya@abc.com"], "id": "3" }] and I have a Query like this - http://localhost:3030/flowz$limit=5&allowedusers[$in[]=rbajaniya@abc.com&$skip=0&$select[]=id&$select[]=alloweduser . But I am not getting all the objects that contain rbajaniya@abc.com . How can I craft my query to get this. I want to get

Haskell: GHC cannot deduce type. Rigid type variable bound by the type signature error

*爱你&永不变心* 提交于 2019-12-10 16:48:48
问题 I'v seen a couple of posts with a similar subject but they don't really help me to solve my problem. So I dare to repeat. Now I have a functions with signature: run' :: Expr query => RethinkDBHandle -> query -> IO [JSON] this is a database query run function. I wrap this function in a pool (pool is already created and irrelevant to the question) to simplify connections. rdb q = withResource pool (\h -> run' (use h $ db "test") q) Essentially, this function has exact the same signature as the

Rethinkdb atomic operations

时光总嘲笑我的痴心妄想 提交于 2019-12-10 14:32:32
问题 Let's say I have a document { id: 1, fruits: [] } fruits here acts as a SET Now I want to atomically add a value to fruits array for document with primary key = 1 OR create such document if it does not exist(i.e. use SetInsert ReQL under the hood) I also need to do the same for increment(ReQL .Add) Obviously this can't be done in client code as it breaks atomicity and I end up with inconsistent data I wish something like this was possible r.table('results').insert({ id: '62c70132-6516-4279

How to get the database and table name from a ReQL query

限于喜欢 提交于 2019-12-10 10:56:18
问题 Suppose I have the following RethinkDB query (as printed in iPython): In [32]: data_to_archive Out[32]: <RqlQuery instance: r.db('sensor_db').table('sensor_data').filter(lambda var_2: (r.row['timestamp'] < (r.now() - r.expr(259200.0)))) > The query is on the database sensor_db and table sensor_data , as is clear from the printed output. Is there any way I can retrieve this information as an attribute of the RqlQuery instance? (The reason I want to do this is to write succinct code: the query,

RethinkDB - Find documents with missing field

帅比萌擦擦* 提交于 2019-12-10 02:44:55
问题 I'm trying to write the most optimal query to find all of the documents that do not have a specific field. Is there any better way to do this than the examples I have listed below? // Get the ids of all documents missing "location" r.db("mydb").table("mytable").filter({location: null},{default: true}).pluck("id") // Get a count of all documents missing "location" r.db("mydb").table("mytable").filter({location: null},{default: true}).count() Right now, these queries take about 300-400ms on a

RethinkDB index for filter + orderby

穿精又带淫゛_ 提交于 2019-12-09 17:25:47
问题 Lets say a comments table has the following structure: id | author | timestamp | body I want to use index for efficiently execute the following query: r.table('comments').getAll("me", {index: "author"}).orderBy('timestamp').run(conn, callback) Is there other efficient method I can use? It looks that currently index is not supported for a filtered result of a table. When creating an index for timestamp and adding it as a hint in orderBy('timestamp', {index: timestamp}) I'm getting the

Is there a better way to “join” data using Horizon?

丶灬走出姿态 提交于 2019-12-08 06:56:48
问题 My data looks something like this in RethinkDb: [appointments] { id: 1, date: "2016-01-01", stylistId: 1, } [stylists] { id: 1, name: "Sue", } On the client, I want to fetch an appointment and have the stylist embedded in the appointment object like so: { id: 1, date: "2016-01-01", stylist: { id: 1, name: "Sue", } } I can achieve something close using this query: return this.hz('appointments') .find(appointmentId) .fetch() .toPromise() .then(appointment => { return this.hz('stylists').find

How do I create a compound multi-index in rethinkdb?

爱⌒轻易说出口 提交于 2019-12-07 06:47:23
问题 I am using Rethinkdb 1.10.1 with the official python driver. I have a table of tagged things which are associated to one user: { "id": "PK", "user_id": "USER_PK", "tags": ["list", "of", "strings"], // Other fields... } I want to query by user_id and tag (say, to find all the things by user "tawmas" with tag "tag"). Starting with Rethinkdb 1.10 I can create a multi-index like this: r.table('things').index_create('tags', multi=True).run(conn) My query would then be: res = (r.table('things')

RethinkDB - Left join where joined_table.identifier is null?

依然范特西╮ 提交于 2019-12-06 16:33:33
I have two tables in a RethinkDB database that represent a one-to-many relationship. Consider the following two tables: t1 ParentId Name 1 lorem 2 ipsum 3 dotor 4 sit 5 amet t2 ChildId ParentId ChildName 1 1 something 2 3 random 3 5 here On t1, ParentId is the primary key, and on t2, there is a secondary index on ParentId. I want to find which parents don't have a child. The operation in SQL (MSSQL to be exact) looks like this: SELECT t1.* FROM t1 LEFT OUTER JOIN t2 ON t2.ParentId = t1.ParentId WHERE t2.ChildId IS NULL Results: ParentId Name 2 ipsum 4 sit How can I accomplish this similar