@@ -41,6 +41,11 @@ Before You Get Started
41
41
42
42
.. tabs::
43
43
44
+ .. tab:: mongosh
45
+ :tabid: shell
46
+
47
+ `Complete mongosh Application <{+sample-app-url-qe+}/mongosh/>`__
48
+
44
49
.. tab:: Node.js
45
50
:tabid: nodejs
46
51
@@ -83,6 +88,35 @@ Procedure
83
88
84
89
.. tabs-drivers::
85
90
91
+ .. tab::
92
+ :tabid: shell
93
+
94
+ - **kmsProviderName** - The KMS you're using to store your {+cmk-long+}.
95
+ Set this variable to ``"local"`` for this tutorial.
96
+ - **uri** - Your MongoDB deployment connection URI. Set your connection
97
+ URI in the ``MONGODB_URI`` environment variable or replace the value
98
+ directly.
99
+ - **keyVaultDatabaseName** - The database in MongoDB where your data
100
+ encryption keys (DEKs) will be stored. Set this variable
101
+ to ``"encryption"``.
102
+ - **keyVaultCollectionName** - The collection in MongoDB where your DEKs
103
+ will be stored. Set this variable to ``"__keyVault"``.
104
+ - **keyVaultNamespace** - The namespace in MongoDB where your DEKs will
105
+ be stored. Set this variable to the values of the ``keyVaultDatabaseName``
106
+ and ``keyVaultCollectionName`` variables, separated by a period.
107
+ - **encryptedDatabaseName** - The database in MongoDB where your encrypted
108
+ data will be stored. Set this variable to ``"medicalRecords"``.
109
+ - **encryptedCollectionName** - The collection in MongoDB where your encrypted
110
+ data will be stored. Set this variable to ``"patients"``.
111
+
112
+ You can declare these variables by using the following code:
113
+
114
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
115
+ :start-after: // start-setup-application-variables
116
+ :end-before: // end-setup-application-variables
117
+ :language: javascript
118
+ :dedent:
119
+
86
120
.. tab::
87
121
:tabid: nodejs
88
122
@@ -255,6 +289,15 @@ Procedure
255
289
256
290
.. tabs-drivers::
257
291
292
+ .. tab::
293
+ :tabid: shell
294
+
295
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-helpers.js
296
+ :start-after: start-generate-local-key
297
+ :end-before: end-generate-local-key
298
+ :language: javascript
299
+ :dedent:
300
+
258
301
.. tab::
259
302
:tabid: nodejs
260
303
@@ -319,6 +362,15 @@ Procedure
319
362
320
363
.. tabs-drivers::
321
364
365
+ .. tab::
366
+ :tabid: shell
367
+
368
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-helpers.js
369
+ :start-after: start-get-local-key
370
+ :end-before: end-get-local-key
371
+ :language: javascript
372
+ :dedent:
373
+
322
374
.. tab::
323
375
:tabid: nodejs
324
376
@@ -372,6 +424,18 @@ Procedure
372
424
373
425
.. tabs-drivers::
374
426
427
+ .. tab::
428
+ :tabid: shell
429
+
430
+ - The variable containing your Local KMS credentials
431
+ - The namespace of your {+key-vault-long+}
432
+
433
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-helpers.js
434
+ :start-after: // start-auto-encryption-options
435
+ :end-before: // end-auto-encryption-options
436
+ :language: javascript
437
+ :dedent:
438
+
375
439
.. tab::
376
440
:tabid: nodejs
377
441
@@ -447,6 +511,15 @@ Procedure
447
511
448
512
.. tabs-drivers::
449
513
514
+ .. tab::
515
+ :tabid: shell
516
+
517
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
518
+ :start-after: // start-create-client
519
+ :end-before: // end-create-client
520
+ :language: javascript
521
+ :dedent:
522
+
450
523
.. tab::
451
524
:tabid: nodejs
452
525
@@ -502,6 +575,15 @@ Procedure
502
575
503
576
.. tabs-drivers::
504
577
578
+ .. tab::
579
+ :tabid: shell
580
+
581
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
582
+ :start-after: // start-encrypted-fields-map
583
+ :end-before: // end-encrypted-fields-map
584
+ :language: javascript
585
+ :dedent:
586
+
505
587
.. tab::
506
588
:tabid: nodejs
507
589
@@ -555,13 +637,22 @@ Procedure
555
637
556
638
.. step:: Create the Collection
557
639
640
+ Instantiate ``ClientEncryption`` to access the API for the
641
+ encryption helper methods.
642
+
558
643
.. tabs-drivers::
559
644
560
645
.. tab::
561
- :tabid: nodejs
646
+ :tabid: shell
562
647
563
- Instantiate ``ClientEncryption`` to access the API for the
564
- encryption helper methods.
648
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
649
+ :start-after: // start-client-encryption
650
+ :end-before: // end-client-encryption
651
+ :language: javascript
652
+ :dedent:
653
+
654
+ .. tab::
655
+ :tabid: nodejs
565
656
566
657
.. literalinclude:: /includes/qe-tutorials/node/queryable-encryption-helpers.js
567
658
:start-after: // start-client-encryption
@@ -572,9 +663,6 @@ Procedure
572
663
.. tab::
573
664
:tabid: python
574
665
575
- Instantiate ``ClientEncryption`` to access the API for the
576
- encryption helper methods.
577
-
578
666
.. literalinclude:: /includes/qe-tutorials/python/queryable_encryption_helpers.py
579
667
:start-after: # start-client-encryption
580
668
:end-before: # end-client-encryption
@@ -584,9 +672,6 @@ Procedure
584
672
.. tab::
585
673
:tabid: java-sync
586
674
587
- Instantiate ``ClientEncryption`` to access the API for the
588
- encryption helper methods.
589
-
590
675
.. literalinclude:: /includes/qe-tutorials/java/src/main/java/com/mongodb/tutorials/qe/QueryableEncryptionTutorial.java
591
676
:start-after: // start-client-encryption
592
677
:end-before: // end-client-encryption
@@ -596,9 +681,6 @@ Procedure
596
681
.. tab::
597
682
:tabid: go
598
683
599
- Instantiate ``ClientEncryption`` to access the API for the
600
- encryption helper methods.
601
-
602
684
.. literalinclude:: /includes/qe-tutorials/go/queryable_encryption_helpers.go
603
685
:start-after: // start-client-encryption
604
686
:end-before: // end-client-encryption
@@ -608,9 +690,6 @@ Procedure
608
690
.. tab::
609
691
:tabid: csharp
610
692
611
- Instantiate ``ClientEncryption`` to access the API for the
612
- encryption helper methods.
613
-
614
693
.. literalinclude:: /includes/qe-tutorials/csharp/QueryableEncryptionHelpers.cs
615
694
:start-after: // start-client-encryption
616
695
:end-before: // end-client-encryption
@@ -624,6 +703,15 @@ Procedure
624
703
625
704
.. tabs-drivers::
626
705
706
+ .. tab::
707
+ :tabid: shell
708
+
709
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-helpers.js
710
+ :start-after: start-kmip-local-cmk-credentials
711
+ :end-before: end-kmip-local-cmk-credentials
712
+ :language: javascript
713
+ :dedent:
714
+
627
715
.. tab::
628
716
:tabid: nodejs
629
717
@@ -671,6 +759,20 @@ Procedure
671
759
672
760
.. tabs-drivers::
673
761
762
+ .. tab::
763
+ :tabid: shell
764
+
765
+ Create your encrypted collection by using the encryption
766
+ helper method accessed through the ``ClientEncryption`` class.
767
+ This method automatically generates data encryption keys for your
768
+ encrypted fields and creates the encrypted collection:
769
+
770
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
771
+ :start-after: // start-create-encrypted-collection
772
+ :end-before: // end-create-encrypted-collection
773
+ :language: javascript
774
+ :dedent:
775
+
674
776
.. tab::
675
777
:tabid: nodejs
676
778
@@ -760,8 +862,8 @@ Procedure
760
862
After you've added these classes, create your encrypted
761
863
collection by using the encryption helper method accessed
762
864
through the ``ClientEncryption`` class.
763
- This method automatically generates data encryption keys for
764
- your encrypted fields and creates the encrypted collection:
865
+ This method automatically generates data encryption keys for your
866
+ encrypted fields and creates the encrypted collection:
765
867
766
868
.. literalinclude:: /includes/qe-tutorials/go/queryable_encryption_tutorial.go
767
869
:start-after: // start-create-encrypted-collection
@@ -779,7 +881,7 @@ Procedure
779
881
:tabid: csharp
780
882
781
883
The C# version of this tutorial uses separate classes as data models
782
- when creating the encrypted collection .
884
+ to represent the document structure .
783
885
Add the following ``Patient``, ``PatientRecord``, and ``PatientBilling``
784
886
classes to your project:
785
887
@@ -827,6 +929,15 @@ Procedure
827
929
828
930
.. tabs-drivers::
829
931
932
+ .. tab::
933
+ :tabid: shell
934
+
935
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
936
+ :start-after: // start-insert-document
937
+ :end-before: // end-insert-document
938
+ :language: javascript
939
+ :dedent:
940
+
830
941
.. tab::
831
942
:tabid: nodejs
832
943
@@ -879,6 +990,15 @@ Procedure
879
990
880
991
.. tabs-drivers::
881
992
993
+ .. tab::
994
+ :tabid: shell
995
+
996
+ .. literalinclude:: /includes/qe-tutorials/mongosh/queryable-encryption-tutorial.js
997
+ :start-after: // start-find-document
998
+ :end-before: // end-find-document
999
+ :language: javascript
1000
+ :dedent:
1001
+
882
1002
.. tab::
883
1003
:tabid: nodejs
884
1004
0 commit comments