rethinkdb

RethinkDB - Updating nested array

邮差的信 提交于 2019-12-04 16:21:27
问题 I have a survey table that looks like so: { id: Id, date: Date, clients: [{ client_id: Id, contacts: [{ contact_id: Id, score: Number, feedback: String, email: String }] }] } I need to updated the score and feedback fields under a specific contact. Currently, I am running the update like this: function saveScore(obj){ var dfd = q.defer(); var survey = surveys.get(obj.survey_id); survey .pluck({ clients: 'contacts' }) .run() .then(results => { results.clients.forEach((item, outerIndex) => {

rethinkdb with filter and getNearest commands

徘徊边缘 提交于 2019-12-04 11:44:07
How can execute getNearest query about the result of other command, for example a filter command? var point = r.point(-122.422876,37.777128); r.db('test').table('users'). filter({tags : 'tag'}). getNearest(point, {index: 'geodata', maxResults: 30, unit :'km'}) I have a 'users' table: [ {id: 1, tags : ['music', 'cups'], geodata: r.point()} {id: 2, tags: ['music', 'play'], geodata: r.point()} ] First I want to filter by 'tags' field and then return the nearest. The query that I have specified is incorrect, return the follow error: " RqlRuntimeError: Expected type TABLE but found SELECTION " The

Access object properties in Javascript

Deadly 提交于 2019-12-04 06:25:57
问题 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 回答1: You can access like this, user['0']

How can I modify array fields in place?

荒凉一梦 提交于 2019-12-04 05:48:26
Let's say I have this object: { "id": "1a48c847-4fee-4968-8cfd-5f8369c01f64" , "sections": [ { "id": 0 , "title": "s1" } , { "id": 1 , "title": "s2" } , { "id": 2 , "title": "s3" } ] } How can I directly change 2nd title "s2" to other value? without loading the object and save again? Thanks. Update plus the changeAt term: r.table('blog').get("1a48c847-4fee-4968-8cfd-5f8369c01f64").update(function(row){ return { sections: row('sections').changeAt(1, row('sections')(1).merge({title: "s2-modified"})) } } The above is good if you already know the index of the item you want to change. If you need

RethinkDB index for filter + orderby

≯℡__Kan透↙ 提交于 2019-12-04 04:32:56
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 following error: RqlRuntimeError: Indexed order_by can only be performed on a TABLE. in: Joe Doliner This can

Docker安装openstf

邮差的信 提交于 2019-12-03 20:06:01
因为没有linux实体机,先在本地pc的虚拟机上安装,用的最新的ubuntu版本; 首先安装docker,不得不说,因为各种原因,ubuntu默认的源显得不是很稳定,可以修改源文件,指向阿里源,修改方法如下: 1、复制原文件备份 sudo cp /etc/apt/source.list /etc/apt/source.list.bak 2、编辑源列表文件 sudo vim /etc/apt/source.list 3、将原来的列表删除,添加如下内容 deb http://mirrors.aliyun.com/ubuntu/ vivid main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ vivid-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ vivid-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ vivid-proposed main restricted universe multiverse deb http://mirrors.aliyun

How to remove a key from a RethinkDB document?

核能气质少年 提交于 2019-12-03 14:23:16
问题 I'm trying to remove a key from a RethinkDB document. My approaches (which didn't work): r.db('db').table('user').replace(function(row){delete row["key"]; return row}) Other approach: r.db('db').table('user').update({key: null}) This one just sets row.key = null (which looks reasonable). Examples tested on rethinkdb data explorer through web UI. 回答1: Here's the relevant example from the documentation on RethinkDB's website: http://rethinkdb.com/docs/cookbook/python/#removing-a-field-from-a

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

邮差的信 提交于 2019-12-03 10:52:41
问题 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. 回答1: 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 }

Rethinkdb and python driver-unable to connect

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Im having a problem with connecting to my RethinkDB local host using my python driver. The directory structure is: home/rethinkdb/drivers/python. When Im inside this python directory I start the python shell. I type import rethinkdb as r r.connect('localhost', 28015).repl() I get the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "rethinkdb/net.py", line 366, in connect return Connection(host, port, db, auth_key, timeout) File "rethinkdb/net.py", line 136, in __init__ self.reconnect(noreply_wait=False)

How to force binding re-evaluate or re-rendering in Aurelia

大兔子大兔子 提交于 2019-12-03 05:59:13
I am starting with a simple TODO app with Aurelia, RethinkDB & Socket.IO. I seem to have problem with re-rendering or re-evaluating an object that is changed through Socket.IO. So basically, everything works good on the first browser but doesn't get re-rendered in the second browser while displaying the object in the console does show differences in my object. The problem is only on updating an object, it works perfectly on creating/deleting object from the array of todo items. HTML <ul> <li repeat.for="item of items"> <div show.bind="!item.isEditing"> <input type="checkbox" checked.two-way=