You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Provides methods for interacting with a single document within a specific Typesense collection.
12
12
///
13
-
/// This struct is created by calling a method like `client.collection("collection_name").document("document_id")` or `client.collection_of::<MyType>("collection_name").document("document_id")`.
14
-
/// The generic `T` represents the shape of the document and must implement `Serialize` and `DeserializeOwned`.
15
-
/// If `T` is not specified, it defaults to `serde_json::Value` for schemaless interactions.
13
+
/// This struct is created by calling a method like `client.collection_schemaless("collection_name").document("document_id")`
14
+
/// or `client.collection::<MyType>().document("document_id")`.
15
+
/// The generic `D` represents the shape of the document and must implement `Serialize` and `DeserializeOwned`.
16
+
/// If `D` is not specified, it defaults to `serde_json::Value` for schemaless interactions.
16
17
pubstructDocument<'c,'n,D = serde_json::Value>
17
18
where
18
-
D:DeserializeOwned + Serialize + Send + Sync,
19
+
D:DeserializeOwned + Serialize,
19
20
{
20
-
pub(super)client:&'cClient,
21
-
pub(super)collection_name:&'nstr,
22
-
pub(super)document_id:String,
23
-
pub(super)_phantom: std::marker::PhantomData<D>,
21
+
client:&'cClient,
22
+
collection_name:&'nstr,
23
+
document_id:String,
24
+
_phantom: std::marker::PhantomData<D>,
24
25
}
25
26
26
27
impl<'c,'n,D>Document<'c,'n,D>
27
28
where
28
-
D:DeserializeOwned + Serialize + Send + Sync,
29
+
D:DeserializeOwned + Serialize,
29
30
{
30
31
/// Creates a new `Document` instance for a specific document ID.
31
32
#[inline]
@@ -38,10 +39,10 @@ where
38
39
}
39
40
}
40
41
41
-
/// Fetches this individual document from the collection and deserializes it into `T`.
42
+
/// Fetches this individual document from the collection and deserializes it into `D`.
42
43
///
43
44
/// # Returns
44
-
/// A `Result` containing the strongly-typed document `T` if successful.
45
+
/// A `Result` containing the strongly-typed document `D` if successful.
/// * `params` - An optional `DocumentIndexParameters` struct to specify additional parameters, such as `dirty_values` which determines what Typesense should do when the type of a particular field being indexed does not match the previously inferred type for that field, or the one defined in the collection's schema.
63
64
///
64
65
/// # Returns
65
-
/// A `Result` containing the full, updated document deserialized into `T`.
66
+
/// A `Result` containing the full, updated document deserialized into `D`.
66
67
///
67
68
/// # Example
68
69
/// ```no_run
@@ -81,15 +82,15 @@ where
81
82
/// let book_update = serde_json::json!({ "pages": 654 });
82
83
///
83
84
/// // Simple update
84
-
/// let updated_book = client.collection_of::<Book>("books").document("123")
85
+
/// let updated_book = client.collection_named::<Book>("books").document("123")
85
86
/// .update(&book_update, None)
86
87
/// .await?;
87
88
///
88
89
/// // Update with additional parameters
89
90
/// let params = models::DocumentIndexParameters {
0 commit comments