@lowdefy/connection-mongodb 0.0.0-experimental-20231123124425 → 0.0.0-experimental-20240115131502
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.
|
@@ -13,12 +13,22 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { MongoClient } from 'mongodb';
|
|
16
|
+
import { type } from '@lowdefy/helpers';
|
|
16
17
|
async function getCollection({ connection }) {
|
|
17
18
|
const { collection, databaseName, databaseUri, options } = connection;
|
|
19
|
+
if (!type.isString(databaseUri)) {
|
|
20
|
+
throw new Error('Database URI must be a string');
|
|
21
|
+
}
|
|
18
22
|
const client = new MongoClient(databaseUri, options);
|
|
19
23
|
await client.connect();
|
|
20
24
|
try {
|
|
25
|
+
if (!type.isString(databaseName) && !type.isNone(databaseName)) {
|
|
26
|
+
throw new Error('Database name must be a string');
|
|
27
|
+
}
|
|
21
28
|
const db = client.db(databaseName);
|
|
29
|
+
if (!type.isString(collection)) {
|
|
30
|
+
throw new Error('Collection name must be a string');
|
|
31
|
+
}
|
|
22
32
|
return {
|
|
23
33
|
client,
|
|
24
34
|
collection: db.collection(collection)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-mongodb",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-20240115131502",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"dist/*"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lowdefy/helpers": "0.0.0-experimental-
|
|
39
|
+
"@lowdefy/helpers": "0.0.0-experimental-20240115131502",
|
|
40
40
|
"@next-auth/mongodb-adapter": "1.1.3",
|
|
41
|
-
"mongodb": "
|
|
41
|
+
"mongodb": "6.3.0",
|
|
42
42
|
"saslprep": "1.0.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@lowdefy/ajv": "0.0.0-experimental-
|
|
45
|
+
"@lowdefy/ajv": "0.0.0-experimental-20240115131502",
|
|
46
46
|
"@shelf/jest-mongodb": "4.1.7",
|
|
47
47
|
"@swc/cli": "0.1.63",
|
|
48
48
|
"@swc/core": "1.3.99",
|