@openfn/language-mongodb 1.1.1 → 2.0.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/configuration-schema.json +6 -6
- package/dist/index.cjs +9 -9
- package/dist/index.js +9 -9
- package/package.json +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"properties": {
|
|
4
|
-
"
|
|
5
|
-
"title": "Cluster
|
|
4
|
+
"clusterHostname": {
|
|
5
|
+
"title": "Cluster Hostname",
|
|
6
6
|
"type": "string",
|
|
7
|
-
"description": "Your MongoDB cluster
|
|
8
|
-
"format": "
|
|
7
|
+
"description": "Your MongoDB cluster hostname",
|
|
8
|
+
"format": "hostname",
|
|
9
9
|
"minLength": 1,
|
|
10
10
|
"examples": [
|
|
11
11
|
"yourCluster-xxxyzzz.mongodb.net"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"type": "object",
|
|
35
35
|
"additionalProperties": true,
|
|
36
36
|
"required": [
|
|
37
|
-
"
|
|
37
|
+
"clusterHostname",
|
|
38
38
|
"username",
|
|
39
39
|
"password"
|
|
40
40
|
]
|
|
41
|
-
}
|
|
41
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -79,12 +79,12 @@ function execute(...operations) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function connect(state) {
|
|
82
|
-
const {
|
|
82
|
+
const { clusterHostname, username, password } = state.configuration;
|
|
83
83
|
const uri = `mongodb+srv://${encodeURIComponent(
|
|
84
84
|
username
|
|
85
85
|
)}:${encodeURIComponent(
|
|
86
86
|
password
|
|
87
|
-
)}@${
|
|
87
|
+
)}@${clusterHostname}/test?retryWrites=true&w=majority`;
|
|
88
88
|
const client = new MongoClient(uri, { useNewUrlParser: true });
|
|
89
89
|
return new Promise((resolve, reject) => {
|
|
90
90
|
client.connect((err) => {
|
|
@@ -110,7 +110,7 @@ function insertDocuments(params) {
|
|
|
110
110
|
const db = client.db(database);
|
|
111
111
|
const mCollection = db.collection(collection);
|
|
112
112
|
return new Promise((resolve, reject) => {
|
|
113
|
-
mCollection.insertMany(documents, (err,
|
|
113
|
+
mCollection.insertMany(documents, (err, result) => {
|
|
114
114
|
if (err) {
|
|
115
115
|
reject(err);
|
|
116
116
|
state.client.close();
|
|
@@ -118,8 +118,8 @@ function insertDocuments(params) {
|
|
|
118
118
|
console.log(
|
|
119
119
|
`Inserted ${documents.length} documents into the collection`
|
|
120
120
|
);
|
|
121
|
-
console.log(JSON.stringify(
|
|
122
|
-
const nextState = (0, import_language_common.composeNextState)(state,
|
|
121
|
+
console.log(JSON.stringify(result, null, 2));
|
|
122
|
+
const nextState = (0, import_language_common.composeNextState)(state, result);
|
|
123
123
|
if (callback)
|
|
124
124
|
resolve(callback(nextState));
|
|
125
125
|
resolve(nextState);
|
|
@@ -146,7 +146,7 @@ function findDocuments(params) {
|
|
|
146
146
|
state.client.close();
|
|
147
147
|
} else {
|
|
148
148
|
console.log(`Found ${docs.length} documents in the collection`);
|
|
149
|
-
console.log(JSON.stringify(
|
|
149
|
+
console.log(JSON.stringify(docs, null, 2));
|
|
150
150
|
const nextState = (0, import_language_common.composeNextState)(state, docs);
|
|
151
151
|
if (callback)
|
|
152
152
|
resolve(callback(nextState));
|
|
@@ -172,7 +172,7 @@ function updateDocument(params) {
|
|
|
172
172
|
filter,
|
|
173
173
|
{ $set: changes },
|
|
174
174
|
options,
|
|
175
|
-
(err,
|
|
175
|
+
(err, result) => {
|
|
176
176
|
if (err) {
|
|
177
177
|
reject(err);
|
|
178
178
|
state.client.close();
|
|
@@ -182,8 +182,8 @@ function updateDocument(params) {
|
|
|
182
182
|
filter
|
|
183
183
|
)} in the collection.`
|
|
184
184
|
);
|
|
185
|
-
console.log(JSON.stringify(
|
|
186
|
-
const nextState = (0, import_language_common.composeNextState)(state,
|
|
185
|
+
console.log(JSON.stringify(result, null, 2));
|
|
186
|
+
const nextState = (0, import_language_common.composeNextState)(state, result);
|
|
187
187
|
if (callback)
|
|
188
188
|
resolve(callback(nextState));
|
|
189
189
|
resolve(nextState);
|
package/dist/index.js
CHANGED
|
@@ -55,12 +55,12 @@ function execute(...operations) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
function connect(state) {
|
|
58
|
-
const {
|
|
58
|
+
const { clusterHostname, username, password } = state.configuration;
|
|
59
59
|
const uri = `mongodb+srv://${encodeURIComponent(
|
|
60
60
|
username
|
|
61
61
|
)}:${encodeURIComponent(
|
|
62
62
|
password
|
|
63
|
-
)}@${
|
|
63
|
+
)}@${clusterHostname}/test?retryWrites=true&w=majority`;
|
|
64
64
|
const client = new MongoClient(uri, { useNewUrlParser: true });
|
|
65
65
|
return new Promise((resolve, reject) => {
|
|
66
66
|
client.connect((err) => {
|
|
@@ -86,7 +86,7 @@ function insertDocuments(params) {
|
|
|
86
86
|
const db = client.db(database);
|
|
87
87
|
const mCollection = db.collection(collection);
|
|
88
88
|
return new Promise((resolve, reject) => {
|
|
89
|
-
mCollection.insertMany(documents, (err,
|
|
89
|
+
mCollection.insertMany(documents, (err, result) => {
|
|
90
90
|
if (err) {
|
|
91
91
|
reject(err);
|
|
92
92
|
state.client.close();
|
|
@@ -94,8 +94,8 @@ function insertDocuments(params) {
|
|
|
94
94
|
console.log(
|
|
95
95
|
`Inserted ${documents.length} documents into the collection`
|
|
96
96
|
);
|
|
97
|
-
console.log(JSON.stringify(
|
|
98
|
-
const nextState = composeNextState(state,
|
|
97
|
+
console.log(JSON.stringify(result, null, 2));
|
|
98
|
+
const nextState = composeNextState(state, result);
|
|
99
99
|
if (callback)
|
|
100
100
|
resolve(callback(nextState));
|
|
101
101
|
resolve(nextState);
|
|
@@ -122,7 +122,7 @@ function findDocuments(params) {
|
|
|
122
122
|
state.client.close();
|
|
123
123
|
} else {
|
|
124
124
|
console.log(`Found ${docs.length} documents in the collection`);
|
|
125
|
-
console.log(JSON.stringify(
|
|
125
|
+
console.log(JSON.stringify(docs, null, 2));
|
|
126
126
|
const nextState = composeNextState(state, docs);
|
|
127
127
|
if (callback)
|
|
128
128
|
resolve(callback(nextState));
|
|
@@ -148,7 +148,7 @@ function updateDocument(params) {
|
|
|
148
148
|
filter,
|
|
149
149
|
{ $set: changes },
|
|
150
150
|
options,
|
|
151
|
-
(err,
|
|
151
|
+
(err, result) => {
|
|
152
152
|
if (err) {
|
|
153
153
|
reject(err);
|
|
154
154
|
state.client.close();
|
|
@@ -158,8 +158,8 @@ function updateDocument(params) {
|
|
|
158
158
|
filter
|
|
159
159
|
)} in the collection.`
|
|
160
160
|
);
|
|
161
|
-
console.log(JSON.stringify(
|
|
162
|
-
const nextState = composeNextState(state,
|
|
161
|
+
console.log(JSON.stringify(result, null, 2));
|
|
162
|
+
const nextState = composeNextState(state, result);
|
|
163
163
|
if (callback)
|
|
164
164
|
resolve(callback(nextState));
|
|
165
165
|
resolve(nextState);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-mongodb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A language package for working with MongoDb",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"author": "Open Function Group",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"configuration-schema.json"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@openfn/language-common": "^1.
|
|
15
|
+
"@openfn/language-common": "^1.12.0",
|
|
16
16
|
"mongodb": "^3.7.3"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|