Skip to content

Instantly share code, notes, and snippets.

@chrisabrams
Last active June 27, 2016 21:25
Show Gist options
  • Save chrisabrams/033ad8a5e48cbb46d518c1fb533743ec to your computer and use it in GitHub Desktop.
Save chrisabrams/033ad8a5e48cbb46d518c1fb533743ec to your computer and use it in GitHub Desktop.
var times = {
// Last day available to register
end: {
'James': r.time(2016, 7, 3, '-04:00'),
'John': r.time(2016, 7, 2, '-04:00')
},
// First day available to register
start: {
'James': r.time(2016, 7, 2, '-04:00'),
'John': r.time(2016, 7, 1, '-04:00')
}
}
// Doesn't work
r
.db('camp')
.table('campers')
.getAll(r.args(['James', 'John']), {index: 'first_name'})
.filter( (doc) => {
return r
.expr(times.start)(doc('first_name'))
.ge(doc('time'))
.and(r
.expr(times.end)(doc('first_name'))
.le(doc('time')
))
})
// Doesn't work
r
.db('camp')
.table('campers')
.getAll(r.args(['James', 'John']), {index: 'first_name'})
.filter( (doc) => {
return doc('time')
.during(
r.expr(times.start)(doc('first_name')),
r.expr(times.end)(doc('first_name'))
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment