My rethinkdb stores data in the following format.
data = [{
'appName': "app1",
'startTime': "Mon, 14 Feb 2017 05:10:00 GMT",
'endTime': "Mon, 14 Feb 2017 05:15:00 GMT",
'status': "SUCCESS"
},
{
'appName': "app1",
'startTime': "Mon, 13 Feb 2017 05:10:00 GMT",
'endTime': "Mon, 13 Feb 2017 05:15:00 GMT",
'status': "FAILED"
},
{
'appName': "app2",
'startTime': "Mon, 13 Feb 2017 05:10:00 GMT",
'endTime': "Mon, 13 Feb 2017 05:15:00 GMT",
'status': "RUNNING"
}]
I need to fetch the latest information for all apps.
r.table('apps').group('appName').max('startTime').run()
But since my startTime is stored as a string, I can not do a max operation.
I tried updating the values in the table as follows,
r.table('apps').update({'startTimeDate': pytz.timezone('Europe/Rome').localize(datetime.strptime(r.row['startTime'], '%a, %d %b %Y %H:%M:%S GMT'))}).run()
I receive an error:
TypeError: must be string, not Bracket
How do I persist startTime and endTime as date in rethinkdb from string?