Closed tavurth closed 6 years ago
ReQL closures can take multiple arguments. We can't reasonably implement all the possibilities using Rust's type system. Combined with the fact that ReQL has so many commands, I decided to generate the commands automatically straight from the ReQL documentation. To make this possible, I made the following design choices:-
The argument that the command takes must implement reql::IntoArg. As you can see from the second error message, we don't implement it for closures as this is not practical. Instead we use the args
macro to pass in closures. So try this instead:-
let query =
r.db("test")
.table("test")
.filter(args!(|doc| {
doc.has_fields("test").and(doc.get_field("test").type_of().eq("NUMBER"))
}))
.changes()
I see, that makes a lot more sense now, thank you!
I've updated the example code to reflect the filtered change.
I see, that makes a lot more sense now, thank you!
My pleasure :)
I've updated the example code to reflect the filtered change.
Awesome! Let me take a look. Thanks.
So I'm trying to write a simple filter to expand the changelog example so that it notes only changes which match our TestItem implementation, however I can't seem to get any filters working:
Gives me:
Any advice on the filter implementation would be appreciated, I'm rather new to Rust at this point.