Skip to content

Commit 3a67204

Browse files
norareidyrustagir
andauthored
DOCSP-30509: Usage examples landing page (#61)
Co-authored-by: Rea Rustagi <[email protected]>
1 parent ac84687 commit 3a67204

File tree

3 files changed

+103
-6
lines changed

3 files changed

+103
-6
lines changed

snooty.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ intersphinx = [ "https://www.mongodb.com/docs/manual/objects.inv",
88

99
toc_landing_pages = [
1010
"/fundamentals/connections",
11-
"/fundamentals/crud"
11+
"/fundamentals/crud",
12+
"/usage-examples"
1213
]
1314

1415
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"

source/index.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/quick-start
1010
/quick-reference
11+
/usage-examples
1112
/fundamentals
1213
API Documentation <{+api+}/>
1314
/connection-troubleshooting
@@ -18,7 +19,6 @@
1819

1920
..
2021
/whats-new
21-
/usage-examples
2222
/faq
2323

2424
Introduction
@@ -47,11 +47,11 @@ See driver syntax examples for common MongoDB commands in the
4747
.. For a list of new features and changes in each version, see the
4848
.. :ref:`rust-whats-new` section.
4949

50-
.. Usage Examples
51-
.. --------------
50+
Usage Examples
51+
--------------
5252

53-
.. For fully runnable code snippets and explanations for common
54-
.. methods, see :ref:`rust-usage-examples`.
53+
For fully runnable code examples and explanations of common
54+
MongoDB operations, see :ref:`rust-usage-examples`.
5555

5656
Fundamentals
5757
------------

source/usage-examples.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.. _rust-usage-examples:
2+
3+
==============
4+
Usage Examples
5+
==============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Overview
14+
--------
15+
16+
Usage examples show runnable code examples to demonstrate frequently used MongoDB
17+
operations. Each usage example includes the following:
18+
19+
- Description of the MongoDB operation
20+
- Asynchronous and synchronous Rust code examples that you can run in
21+
your own environment
22+
- Output printed by the code example
23+
24+
.. TODO: To learn more about the runtimes offered by the {+driver-short+},
25+
see <add link to runtimes page>.
26+
27+
How to Use the Usage Examples
28+
-----------------------------
29+
30+
The usage examples are designed to run operations on a MongoDB deployment that contains
31+
the Atlas sample datasets. When you run the example code without the sample data, the output
32+
may not match.
33+
34+
Follow this tutorial to set up your MongoDB deployment with the sample data and run the
35+
example code in your development environment. Before performing the following actions,
36+
ensure that you create an Atlas account and deploy a cluster. For information about setting
37+
up an account and a cluster, see the :atlas:`Get Started with Atlas Guide
38+
</getting-started/#atlas-getting-started>`.
39+
40+
.. procedure::
41+
:style: connected
42+
43+
.. step:: Load the Sample Datasets
44+
45+
Follow the instructions on the :atlas:`Load Sample Data </sample-data>` page
46+
to load the sample datasets into your database deployment.
47+
48+
.. step:: Add the Usage Example Code to Your Development Environment
49+
50+
Copy the example code from the usage example page and paste it into a new file in
51+
your preferred directory.
52+
53+
To learn more about creating an application that uses the {+driver-short+}, follow the
54+
:ref:`rust-quickstart`.
55+
56+
.. step:: Replace the Connection String Placeholder
57+
58+
In your example code, replace the ``connection string`` placeholder with your MongoDB
59+
deployment connection string. For example, if your connection string is
60+
``"mongodb+srv://mongodb-example:27017"``, your connection string assignment resembles
61+
the following:
62+
63+
.. code-block:: rust
64+
:copyable: false
65+
66+
let uri = "mongodb+srv://mongodb-example:27017";
67+
68+
.. step:: Run the Usage Example Code
69+
70+
Run your application in your development environment. If you run your Rust applications
71+
on the command line, run the following command:
72+
73+
.. code-block:: bash
74+
75+
cargo run
76+
77+
After completing these steps, you can see the output described in the **Expected Output** section
78+
of the corresponding usage example.
79+
80+
.. Available Usage Examples
81+
.. ------------------------
82+
83+
.. TODO: add Usage Example pages as they are created
84+
- :ref:`Find a Document <rust-find-one-usage>`
85+
- :ref:`Find Multiple Documents <rust-find-usage>`
86+
- :ref:`Insert a Document <rust-insert-one-usage>`
87+
- :ref:`Insert Multiple Documents <rust-insert-many-usage>`
88+
- :ref:`Update a Document <rust-update-one-usage>`
89+
- :ref:`Update Multiple Documents <rust-update-many-usage>`
90+
- :ref:`Replace a Document <rust-replace-usage>`
91+
- :ref:`Delete a Document <rust-delete-one-usage>`
92+
- :ref:`Delete Multiple Documents <rust-delete-many-usage>`
93+
- :ref:`Count Documents <rust-count-usage>`
94+
- :ref:`Find Distinct Values <rust-distinct-usage>`
95+
96+

0 commit comments

Comments
 (0)