Skip to content

Instantly share code, notes, and snippets.

@thelinuxlich
Created August 27, 2014 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thelinuxlich/0e08270bdfa2062fe435 to your computer and use it in GitHub Desktop.
Save thelinuxlich/0e08270bdfa2062fe435 to your computer and use it in GitHub Desktop.
query with between
r.table("errors").between(
["Uncaught Error: Error calling method on NPObject.", "1", r.now().sub(24 * 60 * 60)], ["Uncaught Error: Error calling method on NPObject.", "1", r.now()], {
index: "message_id_created_at"
}
)
@danielmewes
Copy link

What happens if you run this? Do you get an error or does it just not return any results?

I don't see anything obviously wrong with the query. Theoretically this should work.

@danielmewes
Copy link

Another question: How did you create the message_id_created_at index exactly? Does it work as expected in other queries?

@danielmewes
Copy link

Here's an example that works for me.
I suspect something might be wrong with the index or the data types in your case, but that's just a guess.

r.tableCreate('t1')
r.table('t1').insert({message: "foo", client_id: "1", created_at: r.now()})
r.table('t1').indexCreate("message_id_created_at", function(x) {
    return [x("message"), x("client_id"), x("created_at")]; } )
r.table('t1').between(["foo", "1", r.now().sub(24*60*60)], ["foo", "1", r.now()], {index:"message_id_created_at"})

@thelinuxlich
Copy link
Author

I created the index like this:

r.table('t1').indexCreate("message_id_created_at", [r.row("properties")("message"), r.row("client_id"), r.row("created_at")]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment