-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple example usage in README and in example directory
- Loading branch information
1 parent
cf39b5b
commit 1de3574
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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::<DB, _>(&query).to_string(); | ||
|
||
println!("The sql code for `query` is:\n {sql}\n"); | ||
} |