Struct meilisearch_sdk::documents::DocumentQuery
source · pub struct DocumentQuery<'a, Http: HttpClient> {
pub index: &'a Index<Http>,
pub fields: Option<Vec<&'a str>>,
}Fields§
§index: &'a Index<Http>§fields: Option<Vec<&'a str>>The fields that should appear in the documents. By default, all of the fields are present.
Implementations§
source§impl<'a, Http: HttpClient> DocumentQuery<'a, Http>
impl<'a, Http: HttpClient> DocumentQuery<'a, Http>
pub fn new(index: &Index<Http>) -> DocumentQuery<'_, Http>
sourcepub fn with_fields(
&mut self,
fields: impl IntoIterator<Item = &'a str>,
) -> &mut DocumentQuery<'a, Http>
pub fn with_fields( &mut self, fields: impl IntoIterator<Item = &'a str>, ) -> &mut DocumentQuery<'a, Http>
Specify the fields to return in the document.
§Example
let index = client.index("document_query_with_fields");
let mut document_query = DocumentQuery::new(&index);
document_query.with_fields(["title"]);sourcepub async fn execute<T: DeserializeOwned + 'static + Send + Sync>(
&self,
document_id: &str,
) -> Result<T, Error>
pub async fn execute<T: DeserializeOwned + 'static + Send + Sync>( &self, document_id: &str, ) -> Result<T, Error>
Execute the get document query.
§Example
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObject {
id: String,
kind: String,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObjectReduced {
id: String,
}
let document = DocumentQuery::new(&index).with_fields(["id"])
.execute::<MyObjectReduced>("1")
.await
.unwrap();
assert_eq!(
document,
MyObjectReduced { id: "1".to_string() }
);Trait Implementations§
source§impl<'a, Http: Clone + HttpClient> Clone for DocumentQuery<'a, Http>
impl<'a, Http: Clone + HttpClient> Clone for DocumentQuery<'a, Http>
source§fn clone(&self) -> DocumentQuery<'a, Http>
fn clone(&self) -> DocumentQuery<'a, Http>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<'a, Http: Debug + HttpClient> Debug for DocumentQuery<'a, Http>
impl<'a, Http: Debug + HttpClient> Debug for DocumentQuery<'a, Http>
source§impl<'a, Http: HttpClient> Serialize for DocumentQuery<'a, Http>
impl<'a, Http: HttpClient> Serialize for DocumentQuery<'a, Http>
Auto Trait Implementations§
impl<'a, Http> Freeze for DocumentQuery<'a, Http>
impl<'a, Http> RefUnwindSafe for DocumentQuery<'a, Http>where
Http: RefUnwindSafe,
impl<'a, Http> Send for DocumentQuery<'a, Http>
impl<'a, Http> Sync for DocumentQuery<'a, Http>
impl<'a, Http> Unpin for DocumentQuery<'a, Http>
impl<'a, Http> UnwindSafe for DocumentQuery<'a, Http>where
Http: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more