diff --git a/README.md b/README.md index 73d313f..e2846ba 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,17 @@ to [diesel](https://diesel.rs/), the safe, extensible ORM and query builder for This crate also serves as an example of how to extend diesel with database specific features outside of diesel itself as third party crate. + + +## Example Usage + +```rust + +use diesel_full_text_search::*; + +let search = "bar"; + +let query = Foo::table.filter(to_tsvector(Foo::description).matches(to_tsquery(search))); +``` + +For complete examples, see [/examples](./examples). \ No newline at end of file diff --git a/examples/simple.rs b/examples/simple.rs new file mode 100644 index 0000000..0a3bb74 --- /dev/null +++ b/examples/simple.rs @@ -0,0 +1,24 @@ +extern crate diesel; +use diesel::*; + +extern crate diesel_full_text_search; +use diesel_full_text_search::*; + +type DB = diesel::pg::Pg; + +diesel::table! { + foo (id) { + id -> Int4, + description -> Text, + } +} + +fn main() { + let search = "bar"; + + let query = foo::table.filter(to_tsvector(foo::description).matches(to_tsquery(search))); + + let sql = debug_query::(&query).to_string(); + + println!("The sql code for `query` is:\n {sql}\n"); +}