@@ -9,11 +9,11 @@ Modify Schema Validation
9
9
.. contents:: On this page
10
10
:local:
11
11
:backlinks: none
12
- :depth: 1
12
+ :depth: 2
13
13
:class: singlecol
14
14
15
- After you add schema validation to a collection, you can modify your
16
- schema validation at any time. For example, you may decide:
15
+ After you add schema validation to a collection, you can modify
16
+ validation rules at any time. For example, you may decide:
17
17
18
18
- That documents in a ``users`` collection no longer require an email
19
19
address.
@@ -24,8 +24,8 @@ schema validation at any time. For example, you may decide:
24
24
To modify a collection's schema validation, use the :dbcommand:`collMod`
25
25
command and specify the updated validation in the ``validator`` object.
26
26
27
- Context
28
- -------
27
+ About This Task
28
+ ---------------
29
29
30
30
You can modify all components of a schema validation, including its
31
31
rules, validation level, and validation action.
40
40
-----
41
41
42
42
The following procedure creates a collection with validation rules and
43
- then modifies those rules. You will observe the results when inserting
44
- an invalid and valid document.
43
+ then modifies those rules.
45
44
46
45
.. procedure::
47
46
@@ -57,14 +56,14 @@ an invalid and valid document.
57
56
bsonType: "object",
58
57
required: [ "username", "password" ],
59
58
properties: {
60
- name : {
59
+ username : {
61
60
bsonType: "string",
62
61
description: "must be a string and is required"
63
62
},
64
63
password: {
65
64
bsonType: "string",
66
65
minLength: 8,
67
- description: "must be a string of at least 8 characters, and is required"
66
+ description: "must be a string at least 8 characters long , and is required"
68
67
}
69
68
}
70
69
}
@@ -84,7 +83,7 @@ an invalid and valid document.
84
83
bsonType: "object",
85
84
required: [ "username", "password" ],
86
85
properties: {
87
- name : {
86
+ username : {
88
87
bsonType: "string",
89
88
description: "must be a string and is required"
90
89
},
@@ -106,10 +105,15 @@ an invalid and valid document.
106
105
Results
107
106
-------
108
107
109
- The following examples show what happens when you insert a valid and
110
- invalid document into the users collection, and how to handle previously
111
- valid documents that are no longer valid as a result of changes to the
112
- validation rules.
108
+ The following sections show the results of the updated validation in
109
+ these scenarios:
110
+
111
+ - When you insert an invalid document.
112
+
113
+ - When you insert a valid document.
114
+
115
+ - When a previously valid document becomes invalid because of the
116
+ validation rule changes.
113
117
114
118
Insert an Invalid Document
115
119
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments