How can I get one document only by query in RethinkDB?
for an example, I want to get the document by this query below:
let searchQuery = {
name: 'rob'
}
var cursor = await r.table('users').filter(searchQuery).run(connection)
var user = await cursor.toArray()
console.log(user)
Result:
[ { email: 'fooz@bar.com',
id: '00e18124-714b-4298-aa34-5126ebda8828',
name: 'rob' } ]
Filter method actually returns a list of users
with the same name - 'rob'.
I want the result like get
method:
r.table('posts').get('a9849eef-7176-4411-935b-79a6e3c56a74').run(conn, callback);
Result:
{ email: 'fooz@bar.com',
id: '00e18124-714b-4298-aa34-5126ebda8828',
name: 'rob' }
But this method only takes document id.
Any ideas?