Skip to content

Commit 3245d2f

Browse files
authored
Add tenant_token_guide code-samples (#264)
1 parent a6352ed commit 3245d2f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,3 +792,17 @@ landing_getting_started_1: |-
792792
Movie { "id": "5".to_string(), "title": "Moana".to_string() },
793793
Movie { "id": "6".to_string(), "title": "Philadelphia".to_string() }
794794
], Some("reference_number")).await.unwrap();
795+
tenant_token_guide_generate_sdk_1: |-
796+
let api_key = "B5KdX2MY2jV6EXfUs6scSfmC...";
797+
let expires_at = time::macros::datetime!(2025 - 12 - 20 00:00:00 UTC);
798+
let search_rules = json!({ "patient_medical_records": { "filter": "user_id = 1" } });
799+
800+
let token = client.generate_tenant_token(search_rules, api_key, expires_at).unwrap();
801+
tenant_token_guide_search_sdk_1: |-
802+
let front_end_client = Client::new("http://127.0.0.1:7700", token);
803+
let results: SearchResults<Patient> = front_end_client.index("patient_medical_records")
804+
.search()
805+
.with_query("blood test")
806+
.execute()
807+
.await
808+
.unwrap();

0 commit comments

Comments
 (0)