File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 3
3
# Replace the placeholders with your credentials
4
4
uri = "<connection string>"
5
5
6
- # Set the server_api field of the options object to Stable API version 1
6
+ # Sets the server_api field of the options object to Stable API version 1
7
7
options = { server_api : { version : "1" } }
8
8
9
- # Create a new client and connect to the server
9
+ # Creates a new client and connect to the server
10
10
client = Mongo ::Client . new ( uri , options )
11
11
12
12
# start-sample-data
15
15
# end-sample-data
16
16
17
17
# start-index-single
18
- # Create an index on the "title" field
18
+ # Creates an index on the "title" field
19
19
index = collection . indexes . create_one ( { title : 1 } )
20
- puts "Index created: #{ index } "
21
20
# end-index-single
22
21
23
22
# start-index-single-query
24
- # Find a document with the title "Sweethearts"
23
+ # Finds a document with the title "Sweethearts"
25
24
filter = { title : 'Sweethearts' }
26
25
doc = collection . find ( filter ) . first
27
26
33
32
# end-index-single-query
34
33
35
34
# start-check-single-index
36
- # List all indexes on the collection
35
+ # Lists all indexes on the collection
37
36
all_indexes = collection . indexes
38
37
all_indexes . each do |index_spec |
39
38
puts index_spec . to_json
Original file line number Diff line number Diff line change @@ -73,8 +73,8 @@ field index. The following example creates an index in ascending order on the
73
73
:language: ruby
74
74
:copyable:
75
75
76
- Verify the Index's Creation
77
- ---------------------------
76
+ Verify Index Creation
77
+ ---------------------
78
78
79
79
You can verify that the index was created by iterating through the ``indexes`` object
80
80
to list the indexes in the collection. You should see an index for ``title`` in
You can’t perform that action at this time.
0 commit comments