n8n-nodes-base 1.103.3 → 1.104.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.
- package/dist/credentials/BeeminderApi.credentials.d.ts.map +1 -1
- package/dist/credentials/BeeminderApi.credentials.js +1 -7
- package/dist/credentials/BeeminderApi.credentials.js.map +1 -1
- package/dist/credentials/BeeminderOAuth2Api.credentials.d.ts +9 -0
- package/dist/credentials/BeeminderOAuth2Api.credentials.d.ts.map +1 -0
- package/dist/credentials/BeeminderOAuth2Api.credentials.js +51 -0
- package/dist/credentials/BeeminderOAuth2Api.credentials.js.map +1 -0
- package/dist/credentials/CustomerIoApi.credentials.js +2 -2
- package/dist/credentials/CustomerIoApi.credentials.js.map +1 -1
- package/dist/credentials/MicrosoftTeamsOAuth2Api.credentials.d.ts.map +1 -1
- package/dist/credentials/MicrosoftTeamsOAuth2Api.credentials.js +1 -1
- package/dist/credentials/MicrosoftTeamsOAuth2Api.credentials.js.map +1 -1
- package/dist/credentials/SlackApi.credentials.d.ts.map +1 -1
- package/dist/credentials/SlackApi.credentials.js +19 -0
- package/dist/credentials/SlackApi.credentials.js.map +1 -1
- package/dist/credentials/ZscalerZiaApi.credentials.js +2 -2
- package/dist/credentials/ZscalerZiaApi.credentials.js.map +1 -1
- package/dist/known/credentials.json +10 -0
- package/dist/nodes/Airtable/v2/transport/index.js +2 -2
- package/dist/nodes/Airtable/v2/transport/index.js.map +1 -1
- package/dist/nodes/Beeminder/Beeminder.node.d.ts.map +1 -1
- package/dist/nodes/Beeminder/Beeminder.node.functions.d.ts +106 -5
- package/dist/nodes/Beeminder/Beeminder.node.functions.d.ts.map +1 -1
- package/dist/nodes/Beeminder/Beeminder.node.functions.js +87 -10
- package/dist/nodes/Beeminder/Beeminder.node.functions.js.map +1 -1
- package/dist/nodes/Beeminder/Beeminder.node.js +1034 -59
- package/dist/nodes/Beeminder/Beeminder.node.js.map +1 -1
- package/dist/nodes/Beeminder/GenericFunctions.d.ts +1 -1
- package/dist/nodes/Beeminder/GenericFunctions.d.ts.map +1 -1
- package/dist/nodes/Beeminder/GenericFunctions.js +49 -4
- package/dist/nodes/Beeminder/GenericFunctions.js.map +1 -1
- package/dist/nodes/ClickUp/ClickUp.node.d.ts.map +1 -1
- package/dist/nodes/ClickUp/ClickUp.node.js +9 -1
- package/dist/nodes/ClickUp/ClickUp.node.js.map +1 -1
- package/dist/nodes/ClickUp/TaskDescription.d.ts.map +1 -1
- package/dist/nodes/ClickUp/TaskDescription.js +26 -0
- package/dist/nodes/ClickUp/TaskDescription.js.map +1 -1
- package/dist/nodes/Code/ExecutionError.d.ts +1 -1
- package/dist/nodes/Code/ExecutionError.d.ts.map +1 -1
- package/dist/nodes/Code/ExecutionError.js +2 -2
- package/dist/nodes/Code/ExecutionError.js.map +1 -1
- package/dist/nodes/Code/ValidationError.d.ts +1 -1
- package/dist/nodes/Code/ValidationError.d.ts.map +1 -1
- package/dist/nodes/Code/ValidationError.js +2 -2
- package/dist/nodes/Code/ValidationError.js.map +1 -1
- package/dist/nodes/Code/errors/WrappedExecutionError.d.ts +1 -1
- package/dist/nodes/Code/errors/WrappedExecutionError.d.ts.map +1 -1
- package/dist/nodes/Code/errors/WrappedExecutionError.js +2 -2
- package/dist/nodes/Code/errors/WrappedExecutionError.js.map +1 -1
- package/dist/nodes/Ftp/Ftp.node.d.ts.map +1 -1
- package/dist/nodes/Ftp/Ftp.node.js +64 -1
- package/dist/nodes/Ftp/Ftp.node.js.map +1 -1
- package/dist/nodes/Google/BigQuery/v2/actions/database/executeQuery.operation.d.ts.map +1 -1
- package/dist/nodes/Google/BigQuery/v2/actions/database/executeQuery.operation.js +61 -0
- package/dist/nodes/Google/BigQuery/v2/actions/database/executeQuery.operation.js.map +1 -1
- package/dist/nodes/Google/Gmail/GmailTrigger.node.d.ts.map +1 -1
- package/dist/nodes/Google/Gmail/GmailTrigger.node.js +4 -1
- package/dist/nodes/Google/Gmail/GmailTrigger.node.js.map +1 -1
- package/dist/nodes/Google/Sheet/GoogleSheets.node.d.ts.map +1 -1
- package/dist/nodes/Google/Sheet/GoogleSheets.node.js +2 -1
- package/dist/nodes/Google/Sheet/GoogleSheets.node.js.map +1 -1
- package/dist/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.d.ts.map +1 -1
- package/dist/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.js +36 -1
- package/dist/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.js.map +1 -1
- package/dist/nodes/Google/Sheet/v2/actions/sheet/update.operation.d.ts.map +1 -1
- package/dist/nodes/Google/Sheet/v2/actions/sheet/update.operation.js +36 -1
- package/dist/nodes/Google/Sheet/v2/actions/sheet/update.operation.js.map +1 -1
- package/dist/nodes/Google/Sheet/v2/actions/versionDescription.js +1 -1
- package/dist/nodes/Google/Sheet/v2/actions/versionDescription.js.map +1 -1
- package/dist/nodes/Mailcheck/GenericFunctions.js +2 -2
- package/dist/nodes/Mailcheck/GenericFunctions.js.map +1 -1
- package/dist/nodes/Merge/v2/utils.js +4 -4
- package/dist/nodes/Merge/v2/utils.js.map +1 -1
- package/dist/nodes/MongoDb/MongoDb.node.d.ts.map +1 -1
- package/dist/nodes/MongoDb/MongoDb.node.js +314 -204
- package/dist/nodes/MongoDb/MongoDb.node.js.map +1 -1
- package/dist/nodes/MongoDb/MongoDbProperties.d.ts.map +1 -1
- package/dist/nodes/MongoDb/MongoDbProperties.js +135 -0
- package/dist/nodes/MongoDb/MongoDbProperties.js.map +1 -1
- package/dist/nodes/Postgres/PostgresTrigger.functions.js +5 -5
- package/dist/nodes/Postgres/PostgresTrigger.functions.js.map +1 -1
- package/dist/nodes/Postgres/v1/genericFunctions.js +7 -7
- package/dist/nodes/Postgres/v1/genericFunctions.js.map +1 -1
- package/dist/nodes/Postgres/v2/helpers/utils.d.ts +3 -3
- package/dist/nodes/RespondToWebhook/RespondToWebhook.node.d.ts.map +1 -1
- package/dist/nodes/RespondToWebhook/RespondToWebhook.node.js +13 -2
- package/dist/nodes/RespondToWebhook/RespondToWebhook.node.js.map +1 -1
- package/dist/nodes/Slack/SlackTrigger.node.d.ts.map +1 -1
- package/dist/nodes/Slack/SlackTrigger.node.js +9 -2
- package/dist/nodes/Slack/SlackTrigger.node.js.map +1 -1
- package/dist/nodes/Slack/SlackTriggerHelpers.d.ts +1 -0
- package/dist/nodes/Slack/SlackTriggerHelpers.d.ts.map +1 -1
- package/dist/nodes/Slack/SlackTriggerHelpers.js +44 -0
- package/dist/nodes/Slack/SlackTriggerHelpers.js.map +1 -1
- package/dist/nodes/StopAndError/StopAndError.node.d.ts.map +1 -1
- package/dist/nodes/StopAndError/StopAndError.node.js +6 -15
- package/dist/nodes/StopAndError/StopAndError.node.js.map +1 -1
- package/dist/nodes/StopAndError/utils.d.ts +12 -0
- package/dist/nodes/StopAndError/utils.d.ts.map +1 -0
- package/dist/nodes/StopAndError/utils.js +31 -0
- package/dist/nodes/StopAndError/utils.js.map +1 -0
- package/dist/nodes/Transform/utils/utils.js +2 -2
- package/dist/nodes/Transform/utils/utils.js.map +1 -1
- package/dist/nodes/Venafi/Datacenter/GenericFunctions.js +2 -2
- package/dist/nodes/Venafi/Datacenter/GenericFunctions.js.map +1 -1
- package/dist/nodes/Webhook/Webhook.node.d.ts.map +1 -1
- package/dist/nodes/Webhook/Webhook.node.js +11 -0
- package/dist/nodes/Webhook/Webhook.node.js.map +1 -1
- package/dist/nodes/Webhook/error.d.ts +1 -1
- package/dist/nodes/Webhook/error.d.ts.map +1 -1
- package/dist/nodes/Webhook/error.js +2 -2
- package/dist/nodes/Webhook/error.js.map +1 -1
- package/dist/nodes/Wordpress/PostDescription.d.ts.map +1 -1
- package/dist/nodes/Wordpress/PostDescription.js +14 -0
- package/dist/nodes/Wordpress/PostDescription.js.map +1 -1
- package/dist/nodes/Wordpress/PostInterface.d.ts +1 -0
- package/dist/nodes/Wordpress/PostInterface.d.ts.map +1 -1
- package/dist/nodes/Wordpress/Wordpress.node.d.ts.map +1 -1
- package/dist/nodes/Wordpress/Wordpress.node.js +6 -0
- package/dist/nodes/Wordpress/Wordpress.node.js.map +1 -1
- package/dist/typecheck.tsbuildinfo +1 -1
- package/dist/types/credentials.json +4 -3
- package/dist/types/nodes.json +13 -13
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +57 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +9 -7
|
@@ -68,258 +68,368 @@ class MongoDb {
|
|
|
68
68
|
const credentials = await this.getCredentials('mongoDb');
|
|
69
69
|
const { database, connectionString } = (0, GenericFunctions_1.validateAndResolveMongoCredentials)(this, credentials);
|
|
70
70
|
const client = await (0, GenericFunctions_1.connectMongoClient)(connectionString, credentials);
|
|
71
|
-
const mdb = client.db(database);
|
|
72
71
|
let returnData = [];
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
queryParameter
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
72
|
+
try {
|
|
73
|
+
const mdb = client.db(database);
|
|
74
|
+
const items = this.getInputData();
|
|
75
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
76
|
+
const nodeVersion = this.getNode().typeVersion;
|
|
77
|
+
let itemsLength = items.length ? 1 : 0;
|
|
78
|
+
let fallbackPairedItems = null;
|
|
79
|
+
if (nodeVersion >= 1.1) {
|
|
80
|
+
itemsLength = items.length;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
fallbackPairedItems = (0, utilities_1.generatePairedItemData)(items.length);
|
|
84
|
+
}
|
|
85
|
+
if (operation === 'aggregate') {
|
|
86
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
87
|
+
try {
|
|
88
|
+
const queryParameter = JSON.parse(this.getNodeParameter('query', i));
|
|
89
|
+
if (queryParameter._id && typeof queryParameter._id === 'string') {
|
|
90
|
+
queryParameter._id = new mongodb_1.ObjectId(queryParameter._id);
|
|
91
|
+
}
|
|
92
|
+
const query = mdb
|
|
93
|
+
.collection(this.getNodeParameter('collection', i))
|
|
94
|
+
.aggregate(queryParameter);
|
|
95
|
+
for (const entry of await query.toArray()) {
|
|
96
|
+
returnData.push({ json: entry, pairedItem: fallbackPairedItems ?? [{ item: i }] });
|
|
97
|
+
}
|
|
96
98
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (this.continueOnFail()) {
|
|
101
|
+
returnData.push({
|
|
102
|
+
json: { error: error.message },
|
|
103
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
104
|
+
});
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
105
108
|
}
|
|
106
|
-
throw error;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.deleteMany(JSON.parse(this.getNodeParameter('query', i)));
|
|
116
|
-
returnData.push({
|
|
117
|
-
json: { deletedCount },
|
|
118
|
-
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
if (this.continueOnFail()) {
|
|
111
|
+
if (operation === 'delete') {
|
|
112
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
113
|
+
try {
|
|
114
|
+
const { deletedCount } = await mdb
|
|
115
|
+
.collection(this.getNodeParameter('collection', i))
|
|
116
|
+
.deleteMany(JSON.parse(this.getNodeParameter('query', i)));
|
|
123
117
|
returnData.push({
|
|
124
|
-
json: {
|
|
118
|
+
json: { deletedCount },
|
|
125
119
|
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
126
120
|
});
|
|
127
|
-
continue;
|
|
128
121
|
}
|
|
129
|
-
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (this.continueOnFail()) {
|
|
124
|
+
returnData.push({
|
|
125
|
+
json: { error: error.message },
|
|
126
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
127
|
+
});
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
if (operation === 'find') {
|
|
135
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
136
|
+
try {
|
|
137
|
+
const queryParameter = JSON.parse(this.getNodeParameter('query', i));
|
|
138
|
+
if (queryParameter._id && typeof queryParameter._id === 'string') {
|
|
139
|
+
queryParameter._id = new mongodb_1.ObjectId(queryParameter._id);
|
|
140
|
+
}
|
|
141
|
+
let query = mdb
|
|
142
|
+
.collection(this.getNodeParameter('collection', i))
|
|
143
|
+
.find(queryParameter);
|
|
144
|
+
const options = this.getNodeParameter('options', i);
|
|
145
|
+
const limit = options.limit;
|
|
146
|
+
const skip = options.skip;
|
|
147
|
+
const projection = options.projection && JSON.parse(options.projection);
|
|
148
|
+
const sort = options.sort && JSON.parse(options.sort);
|
|
149
|
+
if (skip > 0) {
|
|
150
|
+
query = query.skip(skip);
|
|
151
|
+
}
|
|
152
|
+
if (limit > 0) {
|
|
153
|
+
query = query.limit(limit);
|
|
154
|
+
}
|
|
155
|
+
if (sort && Object.keys(sort).length !== 0 && sort.constructor === Object) {
|
|
156
|
+
query = query.sort(sort);
|
|
157
|
+
}
|
|
158
|
+
if (projection &&
|
|
159
|
+
Object.keys(projection).length !== 0 &&
|
|
160
|
+
projection.constructor === Object) {
|
|
161
|
+
query = query.project(projection);
|
|
162
|
+
}
|
|
163
|
+
const queryResult = await query.toArray();
|
|
164
|
+
for (const entry of queryResult) {
|
|
165
|
+
returnData.push({ json: entry, pairedItem: fallbackPairedItems ?? [{ item: i }] });
|
|
166
|
+
}
|
|
150
167
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
query = query.project(projection);
|
|
161
|
-
}
|
|
162
|
-
const queryResult = await query.toArray();
|
|
163
|
-
for (const entry of queryResult) {
|
|
164
|
-
returnData.push({ json: entry, pairedItem: fallbackPairedItems ?? [{ item: i }] });
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (this.continueOnFail()) {
|
|
170
|
+
returnData.push({
|
|
171
|
+
json: { error: error.message },
|
|
172
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
173
|
+
});
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
165
177
|
}
|
|
166
178
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
}
|
|
180
|
+
if (operation === 'findOneAndReplace') {
|
|
181
|
+
fallbackPairedItems = fallbackPairedItems ?? (0, utilities_1.generatePairedItemData)(items.length);
|
|
182
|
+
const fields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('fields', 0));
|
|
183
|
+
const useDotNotation = this.getNodeParameter('options.useDotNotation', 0, false);
|
|
184
|
+
const dateFields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('options.dateFields', 0, ''));
|
|
185
|
+
const updateKey = (this.getNodeParameter('updateKey', 0) || '').trim();
|
|
186
|
+
const updateOptions = this.getNodeParameter('upsert', 0)
|
|
187
|
+
? { upsert: true }
|
|
188
|
+
: undefined;
|
|
189
|
+
const updateItems = (0, GenericFunctions_1.prepareItems)({ items, fields, updateKey, useDotNotation, dateFields });
|
|
190
|
+
for (const item of updateItems) {
|
|
191
|
+
try {
|
|
192
|
+
const filter = { [updateKey]: item[updateKey] };
|
|
193
|
+
if (updateKey === '_id') {
|
|
194
|
+
filter[updateKey] = new mongodb_1.ObjectId(item[updateKey]);
|
|
195
|
+
delete item._id;
|
|
196
|
+
}
|
|
197
|
+
await mdb
|
|
198
|
+
.collection(this.getNodeParameter('collection', 0))
|
|
199
|
+
.findOneAndReplace(filter, item, updateOptions);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (this.continueOnFail()) {
|
|
203
|
+
item.json = { error: error.message };
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
174
207
|
}
|
|
175
|
-
throw error;
|
|
176
208
|
}
|
|
209
|
+
returnData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(updateItems), { itemData: fallbackPairedItems });
|
|
177
210
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
211
|
+
if (operation === 'findOneAndUpdate') {
|
|
212
|
+
fallbackPairedItems = fallbackPairedItems ?? (0, utilities_1.generatePairedItemData)(items.length);
|
|
213
|
+
const fields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('fields', 0));
|
|
214
|
+
const useDotNotation = this.getNodeParameter('options.useDotNotation', 0, false);
|
|
215
|
+
const dateFields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('options.dateFields', 0, ''));
|
|
216
|
+
const updateKey = (this.getNodeParameter('updateKey', 0) || '').trim();
|
|
217
|
+
const updateOptions = this.getNodeParameter('upsert', 0)
|
|
218
|
+
? { upsert: true }
|
|
219
|
+
: undefined;
|
|
220
|
+
const updateItems = (0, GenericFunctions_1.prepareItems)({
|
|
221
|
+
items,
|
|
222
|
+
fields,
|
|
223
|
+
updateKey,
|
|
224
|
+
useDotNotation,
|
|
225
|
+
dateFields,
|
|
226
|
+
isUpdate: nodeVersion >= 1.2,
|
|
227
|
+
});
|
|
228
|
+
for (const item of updateItems) {
|
|
229
|
+
try {
|
|
230
|
+
const filter = { [updateKey]: item[updateKey] };
|
|
231
|
+
if (updateKey === '_id') {
|
|
232
|
+
filter[updateKey] = new mongodb_1.ObjectId(item[updateKey]);
|
|
233
|
+
delete item._id;
|
|
234
|
+
}
|
|
235
|
+
await mdb
|
|
236
|
+
.collection(this.getNodeParameter('collection', 0))
|
|
237
|
+
.findOneAndUpdate(filter, { $set: item }, updateOptions);
|
|
195
238
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
item.json = { error: error.message };
|
|
203
|
-
continue;
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (this.continueOnFail()) {
|
|
241
|
+
item.json = { error: error.message };
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
throw error;
|
|
204
245
|
}
|
|
205
|
-
throw error;
|
|
206
246
|
}
|
|
247
|
+
returnData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(updateItems), { itemData: fallbackPairedItems });
|
|
207
248
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
fallbackPairedItems = fallbackPairedItems ?? (0, utilities_1.generatePairedItemData)(items.length);
|
|
212
|
-
const fields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('fields', 0));
|
|
213
|
-
const useDotNotation = this.getNodeParameter('options.useDotNotation', 0, false);
|
|
214
|
-
const dateFields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('options.dateFields', 0, ''));
|
|
215
|
-
const updateKey = (this.getNodeParameter('updateKey', 0) || '').trim();
|
|
216
|
-
const updateOptions = this.getNodeParameter('upsert', 0)
|
|
217
|
-
? { upsert: true }
|
|
218
|
-
: undefined;
|
|
219
|
-
const updateItems = (0, GenericFunctions_1.prepareItems)({
|
|
220
|
-
items,
|
|
221
|
-
fields,
|
|
222
|
-
updateKey,
|
|
223
|
-
useDotNotation,
|
|
224
|
-
dateFields,
|
|
225
|
-
isUpdate: nodeVersion >= 1.2,
|
|
226
|
-
});
|
|
227
|
-
for (const item of updateItems) {
|
|
249
|
+
if (operation === 'insert') {
|
|
250
|
+
fallbackPairedItems = fallbackPairedItems ?? (0, utilities_1.generatePairedItemData)(items.length);
|
|
251
|
+
let responseData = [];
|
|
228
252
|
try {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
// Prepare the data to insert and copy it to be returned
|
|
254
|
+
const fields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('fields', 0));
|
|
255
|
+
const useDotNotation = this.getNodeParameter('options.useDotNotation', 0, false);
|
|
256
|
+
const dateFields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('options.dateFields', 0, ''));
|
|
257
|
+
const insertItems = (0, GenericFunctions_1.prepareItems)({
|
|
258
|
+
items,
|
|
259
|
+
fields,
|
|
260
|
+
updateKey: '',
|
|
261
|
+
useDotNotation,
|
|
262
|
+
dateFields,
|
|
263
|
+
});
|
|
264
|
+
const { insertedIds } = await mdb
|
|
235
265
|
.collection(this.getNodeParameter('collection', 0))
|
|
236
|
-
.
|
|
266
|
+
.insertMany(insertItems);
|
|
267
|
+
// Add the id to the data
|
|
268
|
+
for (const i of Object.keys(insertedIds)) {
|
|
269
|
+
responseData.push({
|
|
270
|
+
...insertItems[parseInt(i, 10)],
|
|
271
|
+
id: insertedIds[parseInt(i, 10)],
|
|
272
|
+
});
|
|
273
|
+
}
|
|
237
274
|
}
|
|
238
275
|
catch (error) {
|
|
239
276
|
if (this.continueOnFail()) {
|
|
240
|
-
|
|
241
|
-
|
|
277
|
+
responseData = [{ error: error.message }];
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
throw error;
|
|
242
281
|
}
|
|
243
|
-
throw error;
|
|
244
282
|
}
|
|
283
|
+
returnData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: fallbackPairedItems });
|
|
245
284
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (operation === 'insert') {
|
|
249
|
-
fallbackPairedItems = fallbackPairedItems ?? (0, utilities_1.generatePairedItemData)(items.length);
|
|
250
|
-
let responseData = [];
|
|
251
|
-
try {
|
|
252
|
-
// Prepare the data to insert and copy it to be returned
|
|
285
|
+
if (operation === 'update') {
|
|
286
|
+
fallbackPairedItems = fallbackPairedItems ?? (0, utilities_1.generatePairedItemData)(items.length);
|
|
253
287
|
const fields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('fields', 0));
|
|
254
288
|
const useDotNotation = this.getNodeParameter('options.useDotNotation', 0, false);
|
|
255
289
|
const dateFields = (0, GenericFunctions_1.prepareFields)(this.getNodeParameter('options.dateFields', 0, ''));
|
|
256
|
-
const
|
|
290
|
+
const updateKey = (this.getNodeParameter('updateKey', 0) || '').trim();
|
|
291
|
+
const updateOptions = this.getNodeParameter('upsert', 0)
|
|
292
|
+
? { upsert: true }
|
|
293
|
+
: undefined;
|
|
294
|
+
const updateItems = (0, GenericFunctions_1.prepareItems)({
|
|
257
295
|
items,
|
|
258
296
|
fields,
|
|
259
|
-
updateKey
|
|
297
|
+
updateKey,
|
|
260
298
|
useDotNotation,
|
|
261
299
|
dateFields,
|
|
300
|
+
isUpdate: nodeVersion >= 1.2,
|
|
262
301
|
});
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
302
|
+
for (const item of updateItems) {
|
|
303
|
+
try {
|
|
304
|
+
const filter = { [updateKey]: item[updateKey] };
|
|
305
|
+
if (updateKey === '_id') {
|
|
306
|
+
filter[updateKey] = new mongodb_1.ObjectId(item[updateKey]);
|
|
307
|
+
delete item._id;
|
|
308
|
+
}
|
|
309
|
+
await mdb
|
|
310
|
+
.collection(this.getNodeParameter('collection', 0))
|
|
311
|
+
.updateOne(filter, { $set: item }, updateOptions);
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (this.continueOnFail()) {
|
|
315
|
+
item.json = { error: error.message };
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
throw error;
|
|
319
|
+
}
|
|
272
320
|
}
|
|
321
|
+
returnData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(updateItems), { itemData: fallbackPairedItems });
|
|
273
322
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
323
|
+
if (operation === 'listSearchIndexes') {
|
|
324
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
325
|
+
try {
|
|
326
|
+
const collection = this.getNodeParameter('collection', i);
|
|
327
|
+
const indexName = (() => {
|
|
328
|
+
const name = this.getNodeParameter('indexName', i);
|
|
329
|
+
return name.length === 0 ? undefined : name;
|
|
330
|
+
})();
|
|
331
|
+
const cursor = indexName
|
|
332
|
+
? mdb.collection(collection).listSearchIndexes(indexName)
|
|
333
|
+
: mdb.collection(collection).listSearchIndexes();
|
|
334
|
+
const query = await cursor.toArray();
|
|
335
|
+
const result = query.map((json) => ({
|
|
336
|
+
json,
|
|
337
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
338
|
+
}));
|
|
339
|
+
returnData.push(...result);
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
if (this.continueOnFail()) {
|
|
343
|
+
returnData.push({
|
|
344
|
+
json: { error: error.message },
|
|
345
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
346
|
+
});
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
277
351
|
}
|
|
278
|
-
|
|
279
|
-
|
|
352
|
+
}
|
|
353
|
+
if (operation === 'dropSearchIndex') {
|
|
354
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
355
|
+
try {
|
|
356
|
+
const collection = this.getNodeParameter('collection', i);
|
|
357
|
+
const indexName = this.getNodeParameter('indexNameRequired', i);
|
|
358
|
+
await mdb.collection(collection).dropSearchIndex(indexName);
|
|
359
|
+
returnData.push({
|
|
360
|
+
json: {
|
|
361
|
+
[indexName]: true,
|
|
362
|
+
},
|
|
363
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
if (this.continueOnFail()) {
|
|
368
|
+
returnData.push({
|
|
369
|
+
json: { error: error.message },
|
|
370
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
371
|
+
});
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
throw error;
|
|
375
|
+
}
|
|
280
376
|
}
|
|
281
377
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
delete item._id;
|
|
378
|
+
if (operation === 'createSearchIndex') {
|
|
379
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
380
|
+
try {
|
|
381
|
+
const collection = this.getNodeParameter('collection', i);
|
|
382
|
+
const indexName = this.getNodeParameter('indexNameRequired', i);
|
|
383
|
+
const definition = JSON.parse(this.getNodeParameter('indexDefinition', i));
|
|
384
|
+
await mdb.collection(collection).createSearchIndex({
|
|
385
|
+
name: indexName,
|
|
386
|
+
definition,
|
|
387
|
+
});
|
|
388
|
+
returnData.push({
|
|
389
|
+
json: { indexName },
|
|
390
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
if (this.continueOnFail()) {
|
|
395
|
+
returnData.push({
|
|
396
|
+
json: { error: error.message },
|
|
397
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
398
|
+
});
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
throw error;
|
|
307
402
|
}
|
|
308
|
-
await mdb
|
|
309
|
-
.collection(this.getNodeParameter('collection', 0))
|
|
310
|
-
.updateOne(filter, { $set: item }, updateOptions);
|
|
311
403
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
404
|
+
}
|
|
405
|
+
if (operation === 'updateSearchIndex') {
|
|
406
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
407
|
+
try {
|
|
408
|
+
const collection = this.getNodeParameter('collection', i);
|
|
409
|
+
const indexName = this.getNodeParameter('indexNameRequired', i);
|
|
410
|
+
const definition = JSON.parse(this.getNodeParameter('indexDefinition', i));
|
|
411
|
+
await mdb.collection(collection).updateSearchIndex(indexName, definition);
|
|
412
|
+
returnData.push({
|
|
413
|
+
json: { [indexName]: true },
|
|
414
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
if (this.continueOnFail()) {
|
|
419
|
+
returnData.push({
|
|
420
|
+
json: { error: error.message },
|
|
421
|
+
pairedItem: fallbackPairedItems ?? [{ item: i }],
|
|
422
|
+
});
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
throw error;
|
|
316
426
|
}
|
|
317
|
-
throw error;
|
|
318
427
|
}
|
|
319
428
|
}
|
|
320
|
-
returnData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(updateItems), { itemData: fallbackPairedItems });
|
|
321
429
|
}
|
|
322
|
-
|
|
430
|
+
finally {
|
|
431
|
+
await client.close().catch(() => { });
|
|
432
|
+
}
|
|
323
433
|
return [(0, GenericFunctions_1.stringifyObjectIDs)(returnData)];
|
|
324
434
|
}
|
|
325
435
|
}
|