Reputation: 1413
For some reason Rethinkdb is not showing field values for valid objects when using the get()
method:
>>> 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']
When I run the same query using the filter()
method, everything works properly:
>>> 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'[email protected]'}]
Any ideas on why get()
does not show the field values, yet filter()
does? user_id
is the primary key for the 'users' table. Thoughts?
Upvotes: 0
Views: 50
Reputation: 7184
RethinkDB's .get
returns a single object, not an array or a cursor. Your code is returning a list of fields because of the call to list
:
>>> list({'name': 'John', 'user_type': 'company admin'})
['name', 'user_type']
Upvotes: 1