Python中的Rethinkdb客户端不显示字段值

时间:2015-09-02 16:48:38

标签: python rethinkdb rethinkdb-python

出于某种原因,在使用get()方法时,Rethinkdb没有显示有效对象的字段值:

>>> import rethinkdb as r
>>> conn = r.connect( "localhost", 28015)
>>> conn.repl()
<rethinkdb.net.DefaultConnection object at 0x7efd3eab8910>
>>> list(r.db('mydb').table('users').get('4339fe22-7686-4105-9fe7-976871fe552a').run())
[u'group_ids', u'user_id', u'name', u'user_type', u'phone', u'email', u'description']

当我使用filter()方法运行相同的查询时,一切正常:

>>> list(r.db('mydb').table('users').filter(lambda u: u['user_id'] == '4339fe22-7686-4105-9fe7-976871fe552a').run())
[{u'group_ids': [u'a75f9f5a-d5a9-4c2b-8e75-1d1bba5de63e'], u'user_id': u'4339fe22-7686-4105-9fe7-976871fe552a', u'name': u'John', u'user_type': u'company admin', u'phone': u'(...) ...-....', u'email': u'john@example.com'}]

关于为什么get()没有显示字段值的任何想法,但filter()呢? user_id是“用户”表的主键。想法?

1 个答案:

答案 0 :(得分:1)

RethinkDB的.get返回单个对象,而不是数组或游标。由于调用list

,您的代码返回了字段列表
>>> list({'name': 'John', 'user_type': 'company admin'})
['name', 'user_type']