@@ -48,30 +48,30 @@ An application displays movie viewer and revenue information.
48
48
Consider the following ``screenings`` collection:
49
49
50
50
.. code-block:: javascript
51
-
52
- // screenings collection
53
-
54
- {
55
- "theater" : "Alger Cinema ",
56
- "location" : "Lakeview, OR ",
57
- "movie_title": "Reservoir Dogs" ,
58
- "num_viewers": 344,
59
- "revenue": 3440
60
- }
61
- {
62
- "theater" : "City Cinema ",
63
- "location" : "New York, NY ",
64
- "movie_title": "Reservoir Dogs" ,
65
- "num_viewers": 1496,
66
- "revenue": 22440
67
- }
68
- {
69
- "theater" : "Overland Park Cinema ",
70
- "location" : "Boise, ID ",
71
- "movie_title": "Reservoir Dogs" ,
72
- "num_viewers": 760,
73
- "revenue": 7600
74
- }
51
+
52
+ db. screenings.insertMany( [
53
+ {
54
+ theater : "Alger Cinema",
55
+ location : "Lakeview, OR ",
56
+ movie_title : "Reservoir Dogs ",
57
+ num_viewers : 344 ,
58
+ revenue : 3440
59
+ },
60
+ {
61
+ theater : "City Cinema",
62
+ location : "New York, NY ",
63
+ movie_title : "Reservoir Dogs ",
64
+ num_viewers : 1496 ,
65
+ revenue : 22440
66
+ },
67
+ {
68
+ theater : "Overland Park Cinema",
69
+ location : "Boise, ID ",
70
+ movie_title : "Reservoir Dogs ",
71
+ num_viewers : 760 ,
72
+ revenue : 7600
73
+ }
74
+ ] )
75
75
76
76
Users often want to know how many people saw a certain movie and how
77
77
much money that movie made. In this example, to total ``num_viewers``
@@ -82,16 +82,17 @@ is requested, you can compute the total values and store them in a
82
82
``movies`` collection with the movie record itself:
83
83
84
84
.. code-block:: javascript
85
- :emphasize-lines: 5-6
86
-
87
- // movies collection
88
-
89
- {
90
- "title": "Reservoir Dogs",
91
- "total_viewers": 2600,
92
- "total_revenue": 33480,
93
- ...
94
- }
85
+ :copyable: false
86
+ :emphasize-lines: 4-5
87
+
88
+ db.movies.insertOne( [
89
+ {
90
+ title : "Reservoir Dogs",
91
+ total_viewers : 2600,
92
+ total_revenue : 33480,
93
+ ...
94
+ }
95
+ ] )
95
96
96
97
In a low write environment, the computation could be done in
97
98
conjunction with any update of the ``screenings`` data.
0 commit comments