Skip to content

Commit a744e7d

Browse files
authored
DOCSP-38307: Update code sample (#202)
1 parent d094c77 commit a744e7d

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

source/fundamentals/time-series.txt

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,38 +57,34 @@ To create a time series collection, pass the following parameters to the
5757
:language: csharp
5858
:dedent:
5959

60-
To check if you successfully created the collection, send the
61-
``"listCollections"`` command to the ``RunCommand()`` method as shown in the following
62-
example:
60+
To check if you successfully created the collection, use the ``ListCollections()`` or
61+
``ListCollectionsAsync()`` method as shown in the following example:
6362

6463
.. literalinclude:: /includes/fundamentals/code-examples/TimeSeries.cs
65-
:start-after: begin-run-command
66-
:end-before: end-run-command
64+
:start-after: begin-list-collections
65+
:end-before: end-list-collections
6766
:language: csharp
6867
:dedent:
6968

7069
Your output will look similar to the following:
7170

7271
.. code-block:: json
7372

74-
{
75-
"cursor":{
76-
...
77-
"firstBatch":[
78-
{
79-
"name":"september2021",
80-
"type":"timeseries",
81-
"options":{
82-
"timeseries":{
83-
...
84-
}
85-
},
86-
"info":{
87-
"readOnly":false
88-
}
89-
},
90-
...
91-
}
73+
{
74+
"name": "september2021",
75+
"type": "timeseries",
76+
"options": {
77+
"timeseries": {
78+
"timeField": "temperature",
79+
"granularity": "seconds",
80+
"bucketMaxSpanSeconds": 3600
81+
}
82+
},
83+
"info": {
84+
"readOnly": false
85+
}
86+
}
87+
...
9288

9389
Query a Time Series Collection
9490
------------------------------
@@ -114,4 +110,5 @@ guide, see the following API documentation:
114110
- `CreateCollection() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoDatabase.CreateCollection.html>`__
115111
- `CreateCollectionOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.CreateCollectionOptions.html>`__
116112
- `TimeSeriesOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.TimeSeriesOptions.html>`__
117-
- `RunCommand() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoDatabase.RunCommand.html>`__
113+
- `ListCollections() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoDatabase.ListCollections.html>`__
114+
- `ListCollectionsAsync() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoDatabase.ListCollectionsAsync.html>`__

source/includes/fundamentals/code-examples/TimeSeries.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ public static void Main(string[] args)
2121
database.CreateCollection("september2021", collOptions);
2222
// end-time-series
2323

24-
// begin-run-command
25-
var commandResult = database.RunCommand<BsonDocument>(new BsonDocument("listCollections", 1 ));
26-
Console.WriteLine(commandResult.ToJson());
27-
// end-run-command
24+
// begin-list-collections
25+
var collections = database.ListCollections().ToList();
26+
foreach (var collection in collections) {
27+
Console.WriteLine(collection);
28+
}
29+
// end-list-collections
2830
}
29-
3031
}

0 commit comments

Comments
 (0)