File: articles.js

package info (click to toggle)
mongodb 1%3A3.2.11-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 196,404 kB
  • sloc: cpp: 1,412,793; ansic: 504,961; python: 78,522; perl: 5,837; sh: 5,661; java: 4,202; makefile: 1,784; pascal: 617; xml: 176; asm: 128
file content (44 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* sample articles for aggregation demonstrations */

// make sure we're using the right db; this is the same as "use mydb;" in shell
db = db.getSiblingDB("aggdb");
db.article.drop();

db.article.save({
    _id: 1,
    title: "this is my title",
    author: "bob",
    posted: new Date(1079895594000),
    pageViews: 5,
    tags: ["fun", "good", "fun"],
    comments: [{author: "joe", text: "this is cool"}, {author: "sam", text: "this is bad"}],
    other: {foo: 5}
});

db.article.save({
    _id: 2,
    title: "this is your title",
    author: "dave",
    posted: new Date(1912392670000),
    pageViews: 7,
    tags: ["fun", "nasty"],
    comments: [
        {author: "barbara", text: "this is interesting"},
        {author: "jenny", text: "i like to play pinball", votes: 10}
    ],
    other: {bar: 14}
});

db.article.save({
    _id: 3,
    title: "this is some other title",
    author: "jane",
    posted: new Date(978239834000),
    pageViews: 6,
    tags: ["nasty", "filthy"],
    comments: [
        {author: "will", text: "i don't like the color"},
        {author: "jenny", text: "can i get that in green?"}
    ],
    other: {bar: 14}
});