I'm getting started with RethinkDB and I'm having some trouble understanding what's going on with some queries I'm running.
The problem is querying objects with date time types from a NodeJS app (using the rethinkdbdash driver) which exposes a JSON API. If I query my objects individually like:
db.table('apples').max('timestamp');
I get JavaScript Dates for timestamp fields, while if I run a group by operator in the query like in:
db.table('apples').group('type').max('timestamp');
I get date time pseudotypes (I think this is the correct name) for the same timestamp fields instead. Something like:
{
"$reql_type$": "TIME",
"epoch_time": 1423077646.772,
"timezone": "-07:00"
}
Is this the expected behaviour? What is the logic behind it?
I would like to return serialized iso8601 dates in my JSON and not this data type to make parsing transparent to clients.
thanks,
UPDATE This was a known issue for versions prior to 2.2.7. Fixed here.
That looks like a bug in rethinkdbdash. The server always sends times to the clients as pseudotypes (the object with the $reql_type$
field), and the clients are responsible for turning the pseudotypes into native time objects (since drivers in different languages have to do that differently). I'd open a bug at https://github.com/neumino/rethinkdbdash/issues .
I would guess the source of the bug is that group
returns a GROUPED_DATA
pseudotype and rethinkdbdash isn't correctly converting pseudotypes that are inside of other pseudotypes. If you run db.table('apples').group('type').max('timestamp').ungroup()
, that might fix the problem for this query until the driver is patched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With