Skip to content

Update queryable-encryption.mdx #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions docs/challenge/queryable-encryption.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 2
---

# 👐 RUN : Queryable Encryption challenge
# 👐 RUN: Queryable Encryption challenge

:::tip
Remember to add the `--projectId {project_id}`
Expand Down Expand Up @@ -114,7 +114,7 @@ client_encryption = ClientEncryption(
```


### 5. Consider the following sample 'patient' document:
### 5. Consider the following sample "patient" document.
```python
patient_document = {
"patientName": "Jon Doe",
Expand All @@ -129,7 +129,7 @@ patient_document = {
}
```

### 6. Create an encrypted collection based on the following requirements:
### 6. Create an encrypted collection based on the following requirements.
- 'patientId' and 'billing' must be encrypted
- patients will be queried by 'patientId'

Expand Down Expand Up @@ -181,7 +181,7 @@ client_encryption.create_encrypted_collection(
```
</details>

### 5. Insert the sample 'patient' document.
### 7. Insert the sample "patient" document.

```python
encrypted_collection = encrypted_client[encrypted_database_name][encrypted_collection_name]
Expand All @@ -200,14 +200,13 @@ print(f"Inserted document ID: {result.inserted_id}")
</details>
:::

### 6. Find the patient by its 'ssn':
### 8. Find the patient by its "ssn."

```python
find_result = <CODE_BLOCK>
print(find_result)
```


You should be able to successfully retrieve the patient.

:::tip
Expand All @@ -222,15 +221,15 @@ You should be able to successfully retrieve the patient.
</details>
:::

### 7. Make the same query the collection without encryption/decryption.
### 9. Make the same query the collection without encryption/decryption.

```python
reg_mongoclient = MongoClient(new_connection)
reg_collection = reg_mongoclient[encrypted_database_name][encrypted_collection_name]
find_result = <CODE_BLOCK>
print(find_result)
```
You should not be able to find a record since the 'ssn' in the document is encrypted.
You should not be able to find a record since the "ssn" in the document is encrypted.

:::tip
<details>
Expand All @@ -246,7 +245,7 @@ You should not be able to find a record since the 'ssn' in the document is encry
</details>
:::

### 8. Read all documents in the collection without encryption/decryption.
### 10. Read all documents in the collection without encryption/decryption.
```python
all_docs = reg_mongoclient[encrypted_database_name][encrypted_collection_name].find()
print("\nAll documents in the collection:")
Expand All @@ -256,7 +255,6 @@ for doc in all_docs:

You will be able to retrieve the documents, but encrypted data stays encrypted.


## Next Steps
## Next steps

Start the chapter on [On-Premises](./onprem) for self-managed deployments.