user-auth orm and meili changes
This commit is contained in:
@@ -25,9 +25,9 @@ pub struct BookMeili {
|
||||
pub isbn: Vec<String>,
|
||||
}
|
||||
|
||||
pub async fn create_or_update_book(book: BookMeili, client: &Client) {
|
||||
pub async fn create_or_update_book(book: BookMeili, userid: i32, client: &Client) {
|
||||
// An index is where the documents are stored.
|
||||
let books = client.index("books");
|
||||
let books = client.index(format!("books{}",userid));
|
||||
// Add some movies in the index. If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
|
||||
books.add_or_replace(&[
|
||||
book
|
||||
@@ -35,16 +35,16 @@ pub async fn create_or_update_book(book: BookMeili, client: &Client) {
|
||||
}
|
||||
|
||||
|
||||
pub async fn delete_book(bookid: i32, client: &Client) {
|
||||
pub async fn delete_book(bookid: i32, userid: i32, client: &Client) {
|
||||
// An index is where the documents are stored.
|
||||
let books = client.index("books");
|
||||
let books = client.index(format!("books{}",userid));
|
||||
books.delete_document(bookid).await.unwrap();
|
||||
}
|
||||
|
||||
|
||||
pub async fn search_book(search: &str, page: usize, client: &Client) -> Result<(Vec<BookMeili>, usize), meilisearch_sdk::errors::Error> {
|
||||
pub async fn search_book(search: &str, page: usize, userid: i32, client: &Client) -> Result<(Vec<BookMeili>, usize), meilisearch_sdk::errors::Error> {
|
||||
// An index is where the documents are stored.
|
||||
let books = client.index("books");
|
||||
let books = client.index(format!("books{}",userid));
|
||||
let results : SearchResults<BookMeili> = books.search().with_query(search).with_offset((page-1)*12)
|
||||
.execute::<BookMeili>().await.unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user