summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/write_ops.idl
blob: b42b23c2fb81cd53d0ec323b96c3eb055e285e15 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Copyright (C) 2017 MongoDB Inc.
#
# This program is free software: you can redistribute it and/or  modify

#    Copyright (C) 2018-present MongoDB, Inc.
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the Server Side Public License, version 1,
#    as published by MongoDB, Inc.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    Server Side Public License for more details.
#
#    You should have received a copy of the Server Side Public License
#    along with this program. If not, see
#    <http://www.mongodb.com/licensing/server-side-public-license>.
#
#    As a special exception, the copyright holders give permission to link the
#    code of portions of this program with the OpenSSL library under certain
#    conditions as described in each individual source file and distribute
#    linked combinations including the program with the OpenSSL library. You
#    must comply with the Server Side Public License in all respects for
#    all of the code used other than as permitted herein. If you modify file(s)
#    with this exception, you may extend this exception to your version of the
#    file(s), but you are not obligated to do so. If you do not wish to do so,
#    delete this exception statement from your version. If you delete this
#    exception statement from all source files in the program, then also delete
#    it in the license file.
#

global:
    cpp_namespace: "mongo::write_ops"
    cpp_includes:
        - "mongo/db/ops/write_ops_parsers.h"

imports:
    - "mongo/db/logical_session_id.idl"

types:
    multi_delete_bool:
        bson_serialization_type: any
        description: "An inverted boolean type used to parse the 'limit' property of the delete
                      command, which has a mandatory value of either 0 or 1, where 0 means multi
                      delete and 1 means delete just one."
        cpp_type: "bool"
        serializer: "::mongo::write_ops::writeMultiDeleteProperty"
        deserializer: "::mongo::write_ops::readMultiDeleteProperty"

structs:

    WriteCommandBase:
        description: "Contains basic information included by all write commands"
        strict: false
        fields:
            bypassDocumentValidation:
                description: "Enables the operation to bypass document validation. This lets you
                              write documents that do not meet the validation requirements."
                type: safeBool
                default: false
            ordered:
                description: "If true, then when an write statement fails, the command returns
                              without executing the remaining statements. If false, then statements
                              are allowed to be executed in parallel and if a statement fails,
                              continue with the remaining statements, if any."
                type: bool
                default: true
            stmtId:
                description: "A statement number relative to the transaction. If this field
                              is set, the statement ids of the contained operation will be
                              implicitly generated based on their offset, starting from the value
                              given. This field is mutually exclusive with 'stmtIds'."
                type: int
                optional: true

            stmtIds:
                description: "An array of statement numbers relative to the transaction. If this
                              field is set, its size must be exactly the same as the number of
                              entries in the corresponding insert/update/delete request. If it is
                              not set, the statement ids of the contained operation will be
                              implicitly generated based on their offset, starting from 'stmtId' or
                              0 if 'stmtId' is not specified. This field is mutually exclusive
                              with 'stmtId'."
                type: array<int>
                optional: true

    UpdateOpEntry:
        description: "Parser for the entries in the 'updates' array of an update command."
        strict: true
        fields:
            q:
                description: "The query that matches documents to update. Uses the same query
                              selectors as used in the 'find' operation."
                type: object
            u:
                description: "Set of modifications to apply."
                type: object
            arrayFilters:
                description: "Specifies which array elements an update modifier should apply to."
                type: array<object>
                optional: true
            multi:
                description: "If true, updates all documents that meet the query criteria. If false,
                              limits the update to one document which meets the query criteria."
                type: bool
                default: false
            upsert:
                description: "If true, perform an insert if no documents match the query. If both
                              upsert and multi are true and no documents match the query, the update
                              operation inserts only a single document."
                type: bool
                default: false
            collation:
                description: "Specifies the collation to use for the operation."
                type: object
                optional: true

    DeleteOpEntry:
        description: "Parser for the entries in the 'deletes' array of a delete command."
        strict: true
        fields:
            q:
                description: "The query that matches documents to delete. Uses the same query
                              selectors as used in the 'find' operation."
                type: object
            limit:
                description: "The number of matching documents to delete. Value of 0 deletes all
                              matching documents and 1 deletes a single document."
                type: multi_delete_bool
                cpp_name: multi
            collation:
                description: "Specifies the collation to use for the operation."
                type: object
                optional: true

commands:

    insert:
        description: "Parser for the 'insert' command."
        strict: true
        namespace: concatenate_with_db
        chained_structs:
            WriteCommandBase: writeCommandBase
        fields:
            documents:
                description: "An array of one or more documents to insert."
                type: array<object>
                supports_doc_sequence: true

    update:
        description: "Parser for the 'update' command."
        strict: true
        namespace: concatenate_with_db
        chained_structs:
            WriteCommandBase: writeCommandBase
        fields:
            updates:
                description: "An array of one or more update statements to perform."
                type: array<UpdateOpEntry>
                supports_doc_sequence: true

    delete:
        description: "Parser for the 'delete' command."
        strict: true
        namespace: concatenate_with_db
        chained_structs:
            WriteCommandBase: writeCommandBase
        fields:
            deletes:
                description: "An array of one or more delete statements to perform."
                type: array<DeleteOpEntry>
                supports_doc_sequence: true