Skip to content

Commit f27a20d

Browse files
jocelyn-mendez1Jocelyn Mendez
andauthored
DOCSP-16310 Creating time series collection using VS code playgrounds (#47)
* DOCSP-16310 & DOCSP-16375 time-series collections in vscode playgrounds * DOCSP-16310 & DOCSP-16375 time-series collections in vscode playgrounds * DOCSP-16310 & DOCSP-16375 time-series collections in vscode playgrounds * DOCSP-16310 & DOCSP-16375 time-series collections in vscode playgrounds * DOCSP-16310 added example * DOCSP-16310 changing steps to create time series * DOCSP-16310 fixed final code block explanation * DOCSP-16310 removed settings.json file to be added to gitignore * DOCSP-16310 removed .DS_Stor file to be added to gitignore * DOCSP-16310 removed .DS_Stor file to be added to gitignore Co-authored-by: Jocelyn Mendez <[email protected]>
1 parent 1087a56 commit f27a20d

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed
29.2 KB
Loading

source/playgrounds.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,4 @@ Consideration for Authentication
212212
/run-agg-pipelines
213213
/export-to-language
214214
/require-modules
215+
/time-series-collections

source/time-series-collections.txt

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
.. _vsce-time-series:
2+
3+
==============================
4+
Create Time Series Collections
5+
==============================
6+
.. default-domain:: mongodb
7+
8+
.. contents:: On this page
9+
:local:
10+
:backlinks: none
11+
:depth: 1
12+
:class: singlecol
13+
14+
.. include:: /includes/fact-vsce-preview.rst
15+
16+
You can create
17+
:manual:`time series collections </core/timeseries-collections/>` using
18+
a MongoDB Playground.
19+
20+
Prerequisites
21+
-------------
22+
23+
If you have not done so already, you must complete the following
24+
prerequisites before you can create a time series collection with a
25+
MongoDB Playground:
26+
27+
- :ref:`Create a connection to a MongoDB deployment
28+
<vsce-connect-task>`.
29+
- :ref:`Activate the connection to the MongoDB deployment
30+
<vsce-activate-connection>`.
31+
32+
Create a Time Series Collection
33+
-------------------------------
34+
35+
Once you connect to your deployment using MongoDB for VS code, use the left
36+
navigation to:
37+
38+
1. Expand an active connection and hover over the database where you want
39+
your collection to exist.
40+
41+
#. Click the :icon-fa5:`plus` icon that appears.
42+
43+
#. A MongoDB playground automatically opens with a template form to create
44+
both regular collections and time series collections.
45+
46+
#. Delete the regular collection form and uncomment the time series form.
47+
48+
#. Fill in the provided fields with details for your time series collection.
49+
50+
#. To run the playground, click the :guilabel:`Play Button` at the top right
51+
of the VS code navigation bar.
52+
53+
After running the playground with the time series collection, the left
54+
navigation will update the collection icon to identify it is a
55+
time series collection.
56+
57+
.. figure:: /images/vsce-time-series-icon.png
58+
:figwidth: 200px
59+
:alt: Image showing time series icon in VS Code extension
60+
61+
.. seealso::
62+
63+
- To learn more about time series collections, see
64+
:manual:`Time Series Collections </core/timeseries-collections/>`
65+
66+
- To add documents to the collection, see
67+
:ref:`vsce-create-doc-playground`.
68+
69+
Example
70+
-------
71+
72+
This example creates a time series collection named ``weather`` in the ``test``
73+
database.
74+
75+
To use this example, start with a collection template from your MongoDB
76+
Playgrounds. Delete the template form for regular collections and keep the
77+
template for time series collections found below the regular collection
78+
template.
79+
80+
.. code-block:: javascript
81+
82+
use('test');
83+
84+
db.createCollection(
85+
"weather",
86+
{
87+
timeseries: {
88+
timeField: "timestamp",
89+
granularity: "hours"
90+
}
91+
}
92+
)
93+
94+
In the example:
95+
96+
- ``use('test')`` selects the database where the collection is added to.
97+
98+
- ``timeseries`` specifies fields to create a time series collection.
99+
100+
- ``timeField: "timestamp"`` names the field that contains the dates in
101+
the time series documents. In this case, it is ``timestamp``.
102+
103+
- ``granularity: "hours"`` defines the time scale by which the documents
104+
are stored.
105+
106+
When you press the :guilabel:`Play Button`, MongoDB for VS Code splits your
107+
Playground and outputs the following result in the Playground Results.json
108+
pane to confirm the creation of the time series collection.
109+
110+
.. code-block:: javascript
111+
112+
{
113+
"ok": 1
114+
}
115+
116+
The ``weather`` collection also appears in your collection list, and is
117+
marked with the time series icon.

0 commit comments

Comments
 (0)