diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 394ebaf..71c75ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,4 +42,4 @@ jobs: - uses: taiki-e/install-action@cargo-hack - name: Build crate - run: cargo hack --feature-powerset build + run: cargo hack --feature-powerset check --all-targets diff --git a/README.md b/README.md index 73d313f..d38bdf7 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). 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"); +}