rethinkdb

socket.io vs RethinkDB changefeed

若如初见. 提交于 2019-12-03 02:02:54
问题 Currently I'm using socket.io without RethinkDB like this: Clients emit events to socket.io, which receives the events, emits to various other clients, and saves to the db for persistence. A new client connecting will get existing data from the db then listen to new events over socket.io. How would switching to RethinkDB and the changefeed help me here? The way I see the same working with RethinkDB is the client could do a POST (which inserts into RethinkDB) instead of emitting to socket.io,

In RethinkDB, what is the easiest way to check if a database or a table exists?

跟風遠走 提交于 2019-12-03 01:22:24
One way I know I can do it is by listing through dbList() and tableList() and then looking for what I want in the results. Is there an easier way? EDIT My goal is to create a table in case it doesn't exist. If you want to create a database if it does not exists, or get a value like "database already exists" if it does exist, you could do something like the following: r.dbList().contains('example_database') .do(function(databaseExists) { return r.branch( databaseExists, { dbs_created: 0 }, r.dbCreate('example_database') ); }).run(); It will return the following if it is created: { "config

socket.io vs RethinkDB changefeed

£可爱£侵袭症+ 提交于 2019-12-02 15:58:09
Currently I'm using socket.io without RethinkDB like this: Clients emit events to socket.io, which receives the events, emits to various other clients, and saves to the db for persistence. A new client connecting will get existing data from the db then listen to new events over socket.io. How would switching to RethinkDB and the changefeed help me here? The way I see the same working with RethinkDB is the client could do a POST (which inserts into RethinkDB) instead of emitting to socket.io, and then socket.io is watching a RethinkDB changefeed and emitting to all clients when it receives new

Access object properties in Javascript

扶醉桌前 提交于 2019-12-02 10:27:09
I am trying to access email and password field but i dont know where this '0' came. I am retrieving object from rethinkdb and it looks good without '0' . But then am using Lodash _.assign() method like this var user = new User var finduser ={} dbuser = finduser // dbuser is the object retrieving from db user = _.assign(user,finduser) I am getting data like this { '0': { 'email': 'email@ymail.com', 'pswd': 'kdkd' } } I just want to access email field You can access like this, user['0'].email or user['0']['email'] you are retrieving array of data from database. That's how the 0 is coming. There

rethinkdb: “RqlRuntimeError: Array over size limit” even when using limit()

两盒软妹~` 提交于 2019-12-01 21:32:13
问题 I'm trying to access a constant number of the latest documents of a table ordered by a "date" key. Note that the date, unfortunately, was implemented (not by me...) such that the value is set as a string, e.g "2014-01-14", or sometimes "2014-01-14 22:22:22". I'm getting a "RqlRuntimeError: Array over size limit 102173" error message when using the following query: r.db('awesome_db').table("main").orderBy(r.desc("date")) I tried to overcome this problem by specifying a constant limit, since

rethinkdb: “RqlRuntimeError: Array over size limit” even when using limit()

匆匆过客 提交于 2019-12-01 19:34:23
I'm trying to access a constant number of the latest documents of a table ordered by a "date" key. Note that the date, unfortunately, was implemented (not by me...) such that the value is set as a string, e.g "2014-01-14", or sometimes "2014-01-14 22:22:22". I'm getting a "RqlRuntimeError: Array over size limit 102173" error message when using the following query: r.db('awesome_db').table("main").orderBy(r.desc("date")) I tried to overcome this problem by specifying a constant limit, since for now I only need the latest 50: r.db('awesome_db').table("main").orderBy(r.desc("date")).limit(50)

RethinkDB / Horizon: Integration with Express: Access Horizon data server-side?

孤者浪人 提交于 2019-12-01 06:32:16
There is an example of express integration on the Horizon.io Github as shown here: Horizon express server example I understand what this example is showing: if you have an existing Express server you can add a horizon server, which exposes a route client-side so they can connect to horizon server via websockets. However, is there is any way for the express part of the server to also access the collections in Horizon? For example, to do things like local authentication, CRON jobs, or have API endpoints that accept PUT/POST requests. From what I understand, a direct connection to the RethinkDB

How to update embedded document?

邮差的信 提交于 2019-12-01 04:44:55
How to update the text of second comment to "new content" { name: 'Me', comments: [{ "author": "Joe S.", "text": "I'm Thirsty" }, { "author": "Adder K.", "text": "old content" }] } Updating the embedded array basically involves two steps: 1. You create a modified version of the whole array. There are multiple operations that you can use to modify an array, and they are listed here: http://www.rethinkdb.com/api/#js:document_manipulation-insert_at In your example, if you know that the document that you want to update is the second element of the array, you would write something like oldArray

RethinkDB / Horizon: Integration with Express: Access Horizon data server-side?

强颜欢笑 提交于 2019-12-01 04:38:36
问题 There is an example of express integration on the Horizon.io Github as shown here: Horizon express server example I understand what this example is showing: if you have an existing Express server you can add a horizon server, which exposes a route client-side so they can connect to horizon server via websockets. However, is there is any way for the express part of the server to also access the collections in Horizon? For example, to do things like local authentication, CRON jobs, or have API

How to update embedded document?

别来无恙 提交于 2019-12-01 02:33:18
问题 How to update the text of second comment to "new content" { name: 'Me', comments: [{ "author": "Joe S.", "text": "I'm Thirsty" }, { "author": "Adder K.", "text": "old content" }] } 回答1: Updating the embedded array basically involves two steps: 1. You create a modified version of the whole array. There are multiple operations that you can use to modify an array, and they are listed here: http://www.rethinkdb.com/api/#js:document_manipulation-insert_at In your example, if you know that the