1db.createCollection("people", {
2 validator: {
3 $jsonSchema: {
4 bsonType: "object",
5 required: [ "name" ],
6 properties: {
7 name: {
8 bsonType: ["string"],
9 description: "must be a string"
10 },
11 friends: {
12 bsonType: ["array"],
13 items : { bsonType: ["string"] },
14 minItems: 0,
15 maxItems: 10,
16 description: "must be a array of string and max is 10"
17 }
18 }
19 }
20 }
21});