Hi,
i am new to rethinkdb. i am facing some issue which i am unsure how to resolve:
i have a table which contains "time" field which is in epoch time and when i execute the command, the error inform me that
"Exception has occurred: ReqlQueryLogicError
Not a TIME pseudotype: 1606588485 in:"
querycount = db.table("cam0").filter(
r.row['time'].during(r.time(2020, 11, 28, 9,2,38, "+08:00"), r.time(2020, 11, 28, 9, 5,21, "+08:00"))
).avg("counts").run(conn)
i believe i need to convert the r.row["time"] to a ReQL time field but i don't know how to do so.
Please advise. thank you
If you're storing the time in epoch, you may compare the time with numeric value.
e.g.
import { TimezoneDate } from 'timezone-date.ts'
let start = new TimezoneDate()
start.timezone = +8
start.setFullYear(2020, 11 - 1, 28)
start.setHours(9, 2, 38)
let end = new TimezoneDate()
end.timezone = +8
end.setFullYear(2020, 11 - 1, 28)
end.setHours(9, 5, 21)
r.table("cam0").filter(
r.row('time').gt(start.getTime()/1000).and(
r.row('time').lt(end.getTime()/1000)
)
).avg('counts').run(conn)
You can use r.epochTime(1606588485) to construct a time value from the seconds number.
thank you both for your kind response.
@srh i believe your suggestion is extension of @beenotung.
But am curious, what about the "during" method, how can it be actually used? Does it meant the row field need to be stored in ReQL date format to be used? if so how can it be done? thank you
https://rethinkdb.com/api/javascript/during
It's nothing more than that.