diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/changestream.txt b/source/archive-reference-files/fundamentals/crud/read-operations/changestream.txt index 13c8d553..b4315de3 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/changestream.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/changestream.txt @@ -1,6 +1,3 @@ -.. _golang-watch-changes: -.. _golang-monitor-changes: - ==================== Monitor Data Changes ==================== diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/count.txt b/source/archive-reference-files/fundamentals/crud/read-operations/count.txt index 6c1ce856..89fce652 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/count.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/count.txt @@ -1,5 +1,3 @@ -.. _golang-count-documents: - =============== Count Documents =============== diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/limit.txt b/source/archive-reference-files/fundamentals/crud/read-operations/limit.txt index 226c97fd..83803351 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/limit.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/limit.txt @@ -1,5 +1,3 @@ -.. _golang-limit: - ==================================== Limit the Number of Returned Results ==================================== diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt b/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt index 9458460f..d7ad895b 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/skip.txt @@ -1,5 +1,3 @@ -.. _golang-skip: - ===================== Skip Returned Results ===================== diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt b/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt index a3fba2c5..4b44a237 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt +++ b/source/archive-reference-files/fundamentals/crud/read-operations/sort.txt @@ -1,5 +1,3 @@ -.. _golang-sort-results: - ============ Sort Results ============ @@ -286,4 +284,4 @@ guide, see the following API Documentation: - `FindOneAndDelete() <{+api+}/mongo#Collection.FindOneAndDelete>`__ - `FindOneAndUpdate() <{+api+}/mongo#Collection.FindOneAndUpdate>`__ - `FindOneAndReplace() <{+api+}/mongo#Collection.FindOneAndReplace>`__ -- `GridFSBucket.Find() <{+api+}/mongo#GridFSBucket.Find>`__ \ No newline at end of file +- `GridFSBucket.Find() <{+api+}/mongo#GridFSBucket.Find>`__ diff --git a/source/crud/insert.txt b/source/crud/insert.txt index 581d8326..6ce815b7 100644 --- a/source/crud/insert.txt +++ b/source/crud/insert.txt @@ -1,8 +1,8 @@ .. _golang-insert-guide: -================= -Insert a Document -================= +================ +Insert Documents +================ .. facet:: :name: genre diff --git a/source/crud/query.txt b/source/crud/query.txt index 9d66f020..f2ec0906 100644 --- a/source/crud/query.txt +++ b/source/crud/query.txt @@ -8,9 +8,10 @@ Query Operations Specify a Query Find Documents + Access Data from a Cursor Specify Documents to Return Specify Fields to Return Count Documents Distinct Field Values - Access Data from a Cursor + Search Text Geospatial Queries diff --git a/source/archive-reference-files/fundamentals/crud/read-operations/text.txt b/source/crud/query/text.txt similarity index 99% rename from source/archive-reference-files/fundamentals/crud/read-operations/text.txt rename to source/crud/query/text.txt index 38505737..63c60027 100644 --- a/source/archive-reference-files/fundamentals/crud/read-operations/text.txt +++ b/source/crud/query/text.txt @@ -1,8 +1,8 @@ .. _golang-search-text: -=========== -Search Text -=========== +===================== +Perform a Text Search +===================== .. meta:: :description: Learn how to perform text searches with the MongoDB Go Driver, including creating text indexes and sorting results by relevance. diff --git a/source/reference/quick-reference.txt b/source/reference/quick-reference.txt index 93a7cc37..aabf724b 100644 --- a/source/reference/quick-reference.txt +++ b/source/reference/quick-reference.txt @@ -5,25 +5,24 @@ Quick Reference =============== .. meta:: - :description: Explore with the MongoDB Go Driver syntax for various commands, including find, insert, update, delete, and more, with links to API documentation and usage examples. + :keywords: code example, summary, copyable + :description: See simple code examples for how to perform a variety of operations in the Go driver. -.. default-domain:: mongodb - -This page shows the driver syntax for several MongoDB commands and links to -their related reference and API documentation. +This page shows the driver syntax for several MongoDB operations in the +{+driver-short+} and provides links to related reference and API +documentation. .. list-table:: :header-rows: 1 :widths: 25 75 - * - Command + * - Operation - Syntax * - | **Find a Document** | | `API Documentation <{+api+}/mongo#Collection.FindOne>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Find Documents Guide ` - .. io-code-block:: :copyable: true @@ -42,8 +41,7 @@ their related reference and API documentation. * - | **Find Multiple Documents** | | `API Documentation <{+api+}/mongo#Collection.Find>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Find Documents Guide ` - .. io-code-block:: :copyable: true @@ -63,8 +61,7 @@ their related reference and API documentation. * - | **Insert a Document** | | `API Documentation <{+api+}/mongo#Collection.InsertOne>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Insert Documents Guide ` - .. code-block:: go :copyable: true @@ -72,16 +69,15 @@ their related reference and API documentation. result, err := coll.InsertOne( context.TODO(), bson.D{ - {"animal", "Dog"}, - {"breed", "Beagle"} + {"firstName", "Aliya"}, + {"lastName", "Sanders"} } ) * - | **Insert Multiple Documents** | | `API Documentation <{+api+}/mongo#Collection.InsertMany>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Insert Documents Guide ` - .. code-block:: go :copyable: true @@ -98,8 +94,7 @@ their related reference and API documentation. * - | **Update a Document** | | `API Documentation <{+api+}/mongo#Collection.UpdateOne>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Update Documents Guide ` - .. io-code-block:: :copyable: true @@ -112,19 +107,18 @@ their related reference and API documentation. bson.D{{"firstName", "Erik"}}, bson.D{{"$set", bson.D{{"age", 28}}}} ) - fmt.Printf("The number of modified documents: %d\n", result.ModifiedCount) + fmt.Printf("Number of modified documents: %d\n", result.ModifiedCount) .. output:: :language: go :visible: false - The number of modified documents: 1 + Number of modified documents: 1 * - | **Update Multiple Documents** | | `API Documentation <{+api+}/mongo#Collection.UpdateMany>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Update Documents Guide ` - .. io-code-block:: :copyable: true @@ -134,21 +128,21 @@ their related reference and API documentation. result, err := coll.UpdateMany( context.TODO(), - bson.D{{"age", bson.D{{"$gte", 58}}}}, - bson.D{{"$set", bson.D{{"description", "Senior"}}}} + bson.D{{"age", bson.D{{"$gte", 65}}}}, + bson.D{{"$set", bson.D{{"classification", "senior"}}}} ) - fmt.Printf("The number of modified documents: %d\n", result.ModifiedCount) + fmt.Printf("Number of modified documents: %d\n", result.ModifiedCount) .. output:: :language: go :visible: false - The number of modified documents: 4 + Number of modified documents: 4 * - | **Update Arrays in Documents** | | `API Documentation <{+api+}/mongo#Collection.UpdateMany>`__ - | :ref:`Fundamentals ` + | :ref:`Update Arrays Guide ` - .. io-code-block:: :copyable: true @@ -159,22 +153,21 @@ their related reference and API documentation. result, err := coll.UpdateMany( context.TODO(), bson.D{}, - bson.D{{"$push", bson.D{{family, "brother"}}}} + bson.D{{"$push", bson.D{{"hobbies", "painting"}}}} ) .. output:: :language: go - :visible: false + :visible: false - [{firstName Xiao}, {family ["brother"]}, ... ] - [{firstName Omar}, {family ["brother", "mother"]}, ... ] + [{firstName Xiao}, {hobbies ["painting"]}, ... ] + [{firstName Omar}, {hobbies ["kayaking", "painting"]}, ... ] ... * - | **Replace a Document** | | `API Documentation <{+api+}/mongo#Collection.ReplaceOne>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Replace Documents Guide ` - .. io-code-block:: :copyable: true @@ -184,21 +177,20 @@ their related reference and API documentation. result, err := coll.ReplaceOne( context.TODO(), - bson.D{{"firstName", "Mick"}}, - bson.D{{"firstName", "Mike"}, {"lastName", "Doe"}} + bson.D{{"firstName", "Mick"}, {"lastName", "Salazar"}}, + bson.D{{"firstName", "Michael"}, {"lastName", "Salazar Jr."}} ) .. output:: :language: go :visible: false - [{{firstName Mike}, {lastName Doe} }] + [{{firstName Michael}, {lastName Salazar Jr.} }] * - | **Delete a Document** | | `API Documentation <{+api+}/mongo#Collection.DeleteOne>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Delete Documents Guide ` - .. code-block:: go :copyable: true @@ -211,8 +203,7 @@ their related reference and API documentation. * - | **Delete Multiple Documents** | | `API Documentation <{+api+}/mongo#Collection.DeleteMany>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Delete Documents Guide ` - .. code-block:: go :copyable: true @@ -225,8 +216,7 @@ their related reference and API documentation. * - | **Bulk Write** | | `API Documentation <{+api+}/mongo#Collection.BulkWrite>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Bulk Operations Guide ` - .. io-code-block:: :copyable: true @@ -253,7 +243,7 @@ their related reference and API documentation. * - | **Monitor Data Changes** | | `API Documentation <{+api+}/mongo#Collection.Watch>`__ - | :ref:`Usage Example ` + | :ref:`Change Streams Guide ` - .. code-block:: go :copyable: true @@ -264,7 +254,7 @@ their related reference and API documentation. * - | **Access Data from a Cursor Iteratively** | | `API Documentation <{+api+}/mongo#Cursor.Next>`__ - | :ref:`Fundamentals ` + | :ref:`Retrieve Documents Individually Reference ` - .. io-code-block:: :copyable: true @@ -288,13 +278,13 @@ their related reference and API documentation. [{firstName Doug} ... ] [{firstName Erik} ...] - [{lastName Chang} ...] + [{firstName Oleg} ...] ... * - | **Access Data from a Cursor as an Array** | | `API Documentation <{+api+}/mongo#Cursor.All>`__ - | :ref:`Fundamentals ` + | :ref:`Retrieve All Documents Reference ` - .. io-code-block:: :copyable: true @@ -313,16 +303,15 @@ their related reference and API documentation. :language: go :visible: false - [{name Mike} ... ] - [{name Edgar} ...] - [{name Freddie} ...] + [{firstName Mike} ... ] + [{firstName Edgar} ...] + [{firstName Freddie} ...] ... * - | **Count Documents** | | `API Documentation <{+api+}/mongo#Collection.CountDocuments>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Count Documents Guide ` - .. io-code-block:: :copyable: true @@ -336,12 +325,12 @@ their related reference and API documentation. :language: go :visible: false - 6 + 17 - * - | **List the Distinct Documents or Field Values** + * - | **List Distinct Field Values** + | | `API Documentation <{+api+}/mongo#Collection.Distinct>`__ - | :ref:`Usage Example ` - | :ref:`Fundamentals ` + | :ref:`Distinct Values Guide ` - .. io-code-block:: :copyable: true @@ -361,7 +350,7 @@ their related reference and API documentation. * - | **Limit the Number of Documents Retrieved** | | `API Documentation <{+api+}/mongo/options#FindOptionsBuilder.SetLimit>`__ - | :ref:`Fundamentals ` + | :ref:`Limit Documents Reference ` - .. io-code-block:: :copyable: true @@ -375,13 +364,13 @@ their related reference and API documentation. :language: go :visible: false - [{breed Beagle} ... ] - [{breed German Shepard} ...] + [{firstName Xiao} ... ] + [{firstName Oleg} ...] * - | **Skip Retrieved Documents** | | `API Documentation <{+api+}/mongo/options#FindOptionsBuilder.SetSkip>`__ - | :ref:`Fundamentals ` + | :ref:`Skip Documents Reference ` - .. io-code-block:: :copyable: true @@ -396,13 +385,13 @@ their related reference and API documentation. :language: go :visible: false - [{item Pen} ... ] - [{item Chair} ...] + [{firstName Sandy} ... ] + [{firstName Michael} ...] - * - | **Sort the Documents When Retrieving Them** + * - | **Sort Retrieved Documents** | | `API Documentation <{+api+}/mongo/options#FindOptionsBuilder.SetSort>`__ - | :ref:`Fundamentals ` + | :ref:`Sort Documents Reference ` - .. io-code-block:: :copyable: true @@ -420,10 +409,10 @@ their related reference and API documentation. [{firstName Jose} {age 7} ... ] [{firstName Om} {age 8} ... ] - * - | **Project Document Fields When Retrieving Them** + * - | **Project Document Fields in Results** | | `API Documentation <{+api+}/mongo/options#FindOptionsBuilder.SetProjection>`__ - | :ref:`Fundamentals ` + | :ref:`Projection Guide ` - .. io-code-block:: :copyable: true @@ -443,14 +432,14 @@ their related reference and API documentation. :language: go :visible: false - [{firstName Lester}] + [{firstName Lester} {lastName Franklin}] [{firstName Wendall} {lastName Griffin}] ... * - | **Create an Index** | | `API Documentation <{+api+}/mongo#IndexView.CreateOne>`__ - | :ref:`Fundamentals ` + | :ref:`Indexes Guide ` - .. code-block:: go :copyable: true @@ -461,7 +450,7 @@ their related reference and API documentation. * - | **Search Text** | | `API Documentation <{+api+}/mongo#Collection.Find>`__ - | :ref:`Fundamentals ` + | :ref:`Search Text Guide ` - .. io-code-block:: :copyable: true @@ -469,11 +458,12 @@ their related reference and API documentation. .. input:: :language: go - // only searches fields with text indexes - cursor, err := coll.Find(context.TODO(), bson.D{{"$text", bson.D{{"$search", "beagle"}}}}) + // Only searches on fields covered by text indexes + cursor, err := coll.Find(context.TODO(), bson.D{{"$text", bson.D{{"$search", "arts"}}}}) .. output:: :language: go :visible: false - [{"firstName": "Emily" , "Description": "I love to play sports and walk my beagle."} ... ] + [{"firstName": "Emily" , "biography": "I am involved with arts and culture in my community."} ... ] + [{"firstName": "Juan" , "biography": "I attended the School of Arts for cello performance."} ... ]