@lowdefy/connection-mongodb 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2024 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import getCollection from '../getCollection.js';
|
|
16
|
+
import { serialize, deserialize } from '../serialize.js';
|
|
17
|
+
import schema from './schema.js';
|
|
18
|
+
async function MongodbBulkWrite({ connection, request }) {
|
|
19
|
+
const deserializedRequest = deserialize(request);
|
|
20
|
+
const { operations, options } = deserializedRequest;
|
|
21
|
+
const { collection, client } = await getCollection({
|
|
22
|
+
connection
|
|
23
|
+
});
|
|
24
|
+
let response;
|
|
25
|
+
try {
|
|
26
|
+
response = await collection.bulkWrite(operations, options);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
await client.close();
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
await client.close();
|
|
32
|
+
return serialize(response);
|
|
33
|
+
}
|
|
34
|
+
MongodbBulkWrite.schema = schema;
|
|
35
|
+
MongodbBulkWrite.meta = {
|
|
36
|
+
checkRead: false,
|
|
37
|
+
checkWrite: true
|
|
38
|
+
};
|
|
39
|
+
export default MongodbBulkWrite;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2024 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
+
export default {
|
|
17
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
18
|
+
title: 'Lowdefy Request Schema - MongoDBBulkWrite',
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: [
|
|
21
|
+
'operations'
|
|
22
|
+
],
|
|
23
|
+
errorMessage: {
|
|
24
|
+
type: 'MongoDBBulkWrite request properties should be an object.',
|
|
25
|
+
required: 'MongoDBBulkWrite request should have required property "operations".'
|
|
26
|
+
},
|
|
27
|
+
properties: {
|
|
28
|
+
operations: {
|
|
29
|
+
type: 'array',
|
|
30
|
+
description: 'Array containing all the write operations for the execution.',
|
|
31
|
+
errorMessage: {
|
|
32
|
+
type: 'MongoDBBulkWrite request property "operations" should be an array.'
|
|
33
|
+
},
|
|
34
|
+
items: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
errorMessage: {
|
|
37
|
+
type: 'MongoDBBulkWrite request property "operations" should be an array of write operation objects.',
|
|
38
|
+
additionalProperties: 'MongoDBBulkWrite operation should be a write operation.',
|
|
39
|
+
maxProperties: 'MongoDBBulkWrite operation should be a write operation.'
|
|
40
|
+
},
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
maxProperties: 1,
|
|
43
|
+
properties: {
|
|
44
|
+
insertOne: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
required: [
|
|
47
|
+
'document'
|
|
48
|
+
],
|
|
49
|
+
errorMessage: {
|
|
50
|
+
type: 'insertOne operation should be an object.',
|
|
51
|
+
required: 'insertOne operation should have required property "document".'
|
|
52
|
+
},
|
|
53
|
+
properties: {
|
|
54
|
+
document: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
description: 'The document to be inserted.',
|
|
57
|
+
errorMessage: {
|
|
58
|
+
type: 'insertOne operation property "document" should be an object.'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
updateOne: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
required: [
|
|
66
|
+
'filter',
|
|
67
|
+
'update'
|
|
68
|
+
],
|
|
69
|
+
errorMessage: {
|
|
70
|
+
type: 'updateOne operation should be an object.',
|
|
71
|
+
required: {
|
|
72
|
+
filter: 'updateOne operation should have required property "filter".',
|
|
73
|
+
update: 'updateOne operation should have required property "update".'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
properties: {
|
|
77
|
+
filter: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
description: 'The filter used to select the document to update.',
|
|
80
|
+
errorMessage: {
|
|
81
|
+
type: 'updateOne operation property "filter" should be an object.'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
update: {
|
|
85
|
+
type: [
|
|
86
|
+
'object',
|
|
87
|
+
'array'
|
|
88
|
+
],
|
|
89
|
+
description: 'The update operations to be applied to the document.',
|
|
90
|
+
errorMessage: {
|
|
91
|
+
type: 'updateOne operation property "update" should be an object or an array.'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
upsert: {
|
|
95
|
+
type: 'boolean',
|
|
96
|
+
description: 'Insert document if no match is found.',
|
|
97
|
+
errorMessage: {
|
|
98
|
+
type: 'updateOne operation property "upsert" should be a boolean.'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
arrayFilters: {
|
|
102
|
+
type: 'array',
|
|
103
|
+
description: 'Array filters for the `$[<identifier>]` array update operator.',
|
|
104
|
+
errorMessage: {
|
|
105
|
+
type: 'updateOne operation property "arrayFilters" should be an array.'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
collation: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
description: 'Specify collation settings for update operation.',
|
|
111
|
+
errorMessage: {
|
|
112
|
+
type: 'updateOne operation property "collation" should be an object.'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
hint: {
|
|
116
|
+
type: [
|
|
117
|
+
'object',
|
|
118
|
+
'string'
|
|
119
|
+
],
|
|
120
|
+
description: 'An optional hint for query optimization.',
|
|
121
|
+
errorMessage: {
|
|
122
|
+
type: 'updateOne operation property "hint" should be an object or a string.'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
updateMany: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
required: [
|
|
130
|
+
'filter',
|
|
131
|
+
'update'
|
|
132
|
+
],
|
|
133
|
+
errorMessage: {
|
|
134
|
+
type: 'updateMany operation should be an object.',
|
|
135
|
+
required: {
|
|
136
|
+
filter: 'updateMany operation should have required property "filter".',
|
|
137
|
+
update: 'updateMany operation should have required property "update".'
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
properties: {
|
|
141
|
+
filter: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
description: 'The filter used to select the documents to update.',
|
|
144
|
+
errorMessage: {
|
|
145
|
+
type: 'updateMany operation property "filter" should be an object.'
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
update: {
|
|
149
|
+
type: [
|
|
150
|
+
'object',
|
|
151
|
+
'array'
|
|
152
|
+
],
|
|
153
|
+
description: 'The update operations to be applied to the document.',
|
|
154
|
+
errorMessage: {
|
|
155
|
+
type: 'updateMany operation property "update" should be an object or an array.'
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
upsert: {
|
|
159
|
+
type: 'boolean',
|
|
160
|
+
description: 'Insert document if no match is found.',
|
|
161
|
+
errorMessage: {
|
|
162
|
+
type: 'updateMany operation property "upsert" should be a boolean.'
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
arrayFilters: {
|
|
166
|
+
type: 'array',
|
|
167
|
+
description: 'Array filters for the `$[<identifier>]` array update operator.',
|
|
168
|
+
errorMessage: {
|
|
169
|
+
type: 'updateMany operation property "arrayFilters" should be an array.'
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
collation: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
description: 'Specify collation settings for update operation.',
|
|
175
|
+
errorMessage: {
|
|
176
|
+
type: 'updateMany operation property "collation" should be an object.'
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
hint: {
|
|
180
|
+
type: [
|
|
181
|
+
'object',
|
|
182
|
+
'string'
|
|
183
|
+
],
|
|
184
|
+
description: 'An optional hint for query optimization.',
|
|
185
|
+
errorMessage: {
|
|
186
|
+
type: 'updateMany operation property "hint" should be an object or a string.'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
deleteOne: {
|
|
192
|
+
type: 'object',
|
|
193
|
+
required: [
|
|
194
|
+
'filter'
|
|
195
|
+
],
|
|
196
|
+
errorMessage: {
|
|
197
|
+
type: 'deleteOne operation should be an object.',
|
|
198
|
+
required: 'deleteOne operation should have required property "filter".'
|
|
199
|
+
},
|
|
200
|
+
properties: {
|
|
201
|
+
filter: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
description: 'The filter used to select the document to update.',
|
|
204
|
+
errorMessage: {
|
|
205
|
+
type: 'deleteOne operation property "filter" should be an object.'
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
collation: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
description: 'Specify collation settings for update operation.',
|
|
211
|
+
errorMessage: {
|
|
212
|
+
type: 'deleteOne operation property "collation" should be an object.'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
deleteMany: {
|
|
218
|
+
type: 'object',
|
|
219
|
+
required: [
|
|
220
|
+
'filter'
|
|
221
|
+
],
|
|
222
|
+
errorMessage: {
|
|
223
|
+
type: 'deleteMany operation should be an object.',
|
|
224
|
+
required: 'deleteMany operation should have required property "filter".'
|
|
225
|
+
},
|
|
226
|
+
properties: {
|
|
227
|
+
filter: {
|
|
228
|
+
type: 'object',
|
|
229
|
+
description: 'The filter used to select the documents to delete.',
|
|
230
|
+
errorMessage: {
|
|
231
|
+
type: 'deleteMany operation property "filter" should be an object.'
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
collation: {
|
|
235
|
+
type: 'object',
|
|
236
|
+
description: 'Specify collation settings for update operation.',
|
|
237
|
+
errorMessage: {
|
|
238
|
+
type: 'deleteMany operation property "collation" should be an object.'
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
replaceOne: {
|
|
244
|
+
type: 'object',
|
|
245
|
+
required: [
|
|
246
|
+
'filter',
|
|
247
|
+
'replacement'
|
|
248
|
+
],
|
|
249
|
+
errorMessage: {
|
|
250
|
+
type: 'replaceOne operation should be an object.',
|
|
251
|
+
required: {
|
|
252
|
+
filter: 'replaceOne operation should have required property "filter".',
|
|
253
|
+
replacement: 'replaceOne operation should have required property "replacement".'
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
properties: {
|
|
257
|
+
filter: {
|
|
258
|
+
type: 'object',
|
|
259
|
+
description: 'The filter used to select the documents to update.',
|
|
260
|
+
errorMessage: {
|
|
261
|
+
type: 'replaceOne operation property "filter" should be an object.'
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
replacement: {
|
|
265
|
+
type: 'object',
|
|
266
|
+
description: 'The document to be inserted.',
|
|
267
|
+
errorMessage: {
|
|
268
|
+
type: 'replaceOne operation property "replacement" should be an object.'
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
upsert: {
|
|
272
|
+
type: 'boolean',
|
|
273
|
+
description: 'Insert document if no match is found.',
|
|
274
|
+
errorMessage: {
|
|
275
|
+
type: 'replaceOne operation property "upsert" should be a boolean.'
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
collation: {
|
|
279
|
+
type: 'object',
|
|
280
|
+
description: 'Specify collation settings for update operation.',
|
|
281
|
+
errorMessage: {
|
|
282
|
+
type: 'replaceOne operation property "collation" should be an object.'
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
hint: {
|
|
286
|
+
type: [
|
|
287
|
+
'object',
|
|
288
|
+
'string'
|
|
289
|
+
],
|
|
290
|
+
description: 'An optional hint for query optimization.',
|
|
291
|
+
errorMessage: {
|
|
292
|
+
type: 'replaceOne operation property "hint" should be an object or a string.'
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
options: {
|
|
301
|
+
type: 'object',
|
|
302
|
+
description: 'Optional settings.',
|
|
303
|
+
errorMessage: {
|
|
304
|
+
type: 'MongoDBBulkWrite request property "options" should be an object.'
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-mongodb",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
{
|
|
21
21
|
"name": "Gerrie van Wyk",
|
|
22
22
|
"url": "https://github.com/Gervwyk"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Stephanie Smit",
|
|
26
|
+
"url": "https://github.com/StephanieJKS"
|
|
23
27
|
}
|
|
24
28
|
],
|
|
25
29
|
"repository": {
|
|
@@ -36,13 +40,13 @@
|
|
|
36
40
|
"dist/*"
|
|
37
41
|
],
|
|
38
42
|
"dependencies": {
|
|
39
|
-
"@lowdefy/helpers": "4.1
|
|
43
|
+
"@lowdefy/helpers": "4.2.1",
|
|
40
44
|
"@next-auth/mongodb-adapter": "1.1.3",
|
|
41
45
|
"mongodb": "6.3.0",
|
|
42
46
|
"saslprep": "1.0.3"
|
|
43
47
|
},
|
|
44
48
|
"devDependencies": {
|
|
45
|
-
"@lowdefy/ajv": "4.1
|
|
49
|
+
"@lowdefy/ajv": "4.2.1",
|
|
46
50
|
"@shelf/jest-mongodb": "4.1.7",
|
|
47
51
|
"@swc/cli": "0.1.63",
|
|
48
52
|
"@swc/core": "1.3.99",
|