def rethinkdb_date_greater(greater_date, comparison_date, relaxed_interval): return r.branch( r.lt(greater_date[0], comparison_date[0]), False, r.eq(greater_date[0], comparison_date[0]), r.branch( r.eq(greater_date[1], 'XX').or_(r.eq(comparison_date[1], 'XX')), relaxed_interval, r.lt(greater_date[1], comparison_date[1]), False, r.eq(greater_date[1], comparison_date[1]), r.branch( r.eq(greater_date[2], 'XX').or_(r.eq(comparison_date[2], 'XX')), relaxed_interval, r.lt(greater_date[2], comparison_date[2]), False, True), True), True)
def get_posts_count(user): return r.table('posts') .filter(r.eq(r['user_id'], user.user_id)) .count()
q.run(conn) # Default connection mode r.set_default_conn(conn) q.run() q1.run() # Specifying batch count/streaming conn.run(q, batch_size=200) # Asyncrhonous preload, though we're not going to do that. # Filter/selectors (the following three queries are equivalent) q = r.table('foo.bar').filter({ 'age' : r.gt(r['candles']), 'name': 'Michel' }) q = r.table('foo.bar').filter(r.all(r.gt(r['age'], r['candles']), r.eq(r['name'], 'Michel'))) q = r.table('foo.bar').filter(r.all(r.gt(r['age'], r['candles'])), r.eq(r['name'], 'Michel'))) q = r.table('foo.bar').filter(r.all(r.gt(r.attr('age'), r.attr('candles')), r.eq(r.attr('name'), 'Michel'))) table('foo.bar').filter(R('age') > R('candles') & R('name') == 'Michel') q = r.table('foo.bar').filter(r.eq(r['foo'], r.add(r['baz'], 5))) # Get single row q = r.table('foo.bar').get(5) # Get row with primary key five q = r.table('foo.bar').get(5, key='bar') # Secondary unique indexes