You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/mongodb/quickstart-go.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ The following snippets are all taken from the `todo.go` file.
69
69
70
70
### Connecting the Go app to Azure Cosmos DB
71
71
72
-
[`clientOptions`](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo/options?tab=doc#ClientOptions) encapsulates the connection string for Azure Cosmos DB, which is passed in using an environment variable (details in the upcoming section). The connection is initialized using [`mongo.NewClient`](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo?tab=doc#NewClient) to which the `clientOptions` instance is passed. [`Ping` function](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo?tab=doc#Client.Ping) is invoked to confirm successful connectivity (it is a fail-fast strategy)
72
+
[`clientOptions`](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo/options?tab=doc#ClientOptions) encapsulates the connection string for Azure Cosmos DB, which is passed in using an environment variable (details in the upcoming section). The connection is initialized using [`mongo.NewClient`](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo?tab=doc#NewClient) to which the `clientOptions` instance is passed. [`Ping` function](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo?tab=doc#Client.Ping) is invoked to confirm successful connectivity (it is a fail-fast strategy).
We pass in a `Todo` struct that contains the description and the status (which is initially set to `pending`)
112
+
We pass in a `Todo` struct that contains the description and the status (which is initially set to `pending`):
113
113
114
114
```go
115
115
type Todo struct {
@@ -120,7 +120,7 @@ type Todo struct {
120
120
```
121
121
### List `todo` items
122
122
123
-
We can list TODOs based on criteria. A [`bson.D`](https://pkg.go.dev/go.mongodb.org/[email protected]/bson?tab=doc#D) is created to encapsulate the filter criteria
123
+
We can list TODOs based on criteria. A [`bson.D`](https://pkg.go.dev/go.mongodb.org/[email protected]/bson?tab=doc#D) is created to encapsulate the filter criteria:
124
124
125
125
```go
126
126
func list(status string) {
@@ -153,7 +153,7 @@ func list(status string) {
153
153
}
154
154
```
155
155
156
-
Finally, the information is rendered in tabular format
156
+
Finally, the information is rendered in tabular format:
157
157
158
158
```go
159
159
todoTable := [][]string{}
@@ -174,7 +174,7 @@ Finally, the information is rendered in tabular format
174
174
175
175
### Update a `todo` item
176
176
177
-
A `todo` can be updated based on its `_id`. A [`bson.D`](https://pkg.go.dev/go.mongodb.org/[email protected]/bson?tab=doc#D) filter is created based on the `_id` and another one is created for the updated information, which is a new status (`completed` or `pending`) in this case. Finally, the [`UpdateOne`](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo?tab=doc#Collection.UpdateOne) function is invoked with the filter and the updated document
177
+
A `todo` can be updated based on its `_id`. A [`bson.D`](https://pkg.go.dev/go.mongodb.org/[email protected]/bson?tab=doc#D) filter is created based on the `_id` and another one is created for the updated information, which is a new status (`completed` or `pending`) in this case. Finally, the [`UpdateOne`](https://pkg.go.dev/go.mongodb.org/[email protected]/mongo?tab=doc#Collection.UpdateOne) function is invoked with the filter and the updated document:
178
178
179
179
```go
180
180
func update(todoid, newStatus string) {
@@ -247,11 +247,11 @@ If `cosmosdb` is not in the list of base commands, reinstall [Azure CLI](/cli/az
247
247
248
248
### Create a resource group
249
249
250
-
Create a [resource group](../../azure-resource-manager/management/overview.md) with the [az group create](/cli/azure/group#az-group-create). An Azure resource group is a logical container into which Azure resources like web apps, databases and storage accounts are deployed and managed.
250
+
Create a [resource group](../../azure-resource-manager/management/overview.md) with the [az group create](/cli/azure/group#az-group-create). An Azure resource group is a logical container into which Azure resources like web apps, databases, and storage accounts are deployed and managed.
251
251
252
252
The following example creates a resource group in the West Europe region. Choose a unique name for the resource group.
253
253
254
-
If you are using Azure Cloud Shell, select **Try It**, follow the onscreen prompts to login, then copy the command into the command prompt.
254
+
If you are using Azure Cloud Shell, select **Try It**, follow the onscreen prompts to log in, then copy the command into the command prompt.
255
255
256
256
```azurecli-interactive
257
257
az group create --name myResourceGroup --location "West Europe"
@@ -323,7 +323,7 @@ The Azure CLI outputs information similar to the following example.
323
323
## Configure the application
324
324
325
325
<a name="devconfig"></a>
326
-
### Export the connection string, MongoDB database and collection names as environment variables.
326
+
### Export the connection string, MongoDB database, and collection names as environment variables.
0 commit comments