I've seen questions very similar to this, but none of the answers are ideal because they're either inefficient or don't work.
I have a database table which has the following rows:
id feed datetime content
I need to iterate over every item in the table where feed
is example
(or any other value; always a string) but the iteration needs to be ordered by datetime
.
Unfortunately I can't do it in memory because there could be hundreds of thousands of entries for a single user.
I've tried modifying code found here and didn't make any progress. I've also adapted the best answer here and get an error when I run this;
print r.db('main').table('data').between([feedid, r.minval], [feedid, r.maxval], index="feedByTime").order_by(index="feedByTime").run(conn)
Which throws this error;
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/rethinkdb/net.py", line 196, in __str__
val_str = ', '.join(map(repr, self.items[:10]))
TypeError: sequence index must be integer, not 'slice'
If I remove index="feedByTime"
from between
, I get this error instead;
rethinkdb.errors.ReqlQueryLogicError: Cannot order by index 'feedByTime' after calling BETWEEN on index 'id'
The index (feedByTime
) was made like so;
r.db('main').table('data').index_create("feedByTime", lambda x: [x["feed"], x["datetime"]]).run(conn)
Any suggestions would be great, thanks in advance.