@lowdefy/connection-mongodb 4.0.0-alpha.26 → 4.0.0-alpha.29
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/package.json +13 -10
- package/dist/auth/adapters/MongoDBAdapter/MongoDBAdapter.js +0 -31
- package/dist/auth/adapters.js +0 -2
- package/dist/connections/MongoDBCollection/MongoDBAggregation/MongoDBAggregation.js +0 -53
- package/dist/connections/MongoDBCollection/MongoDBAggregation/schema.js +0 -42
- package/dist/connections/MongoDBCollection/MongoDBCollection.js +0 -38
- package/dist/connections/MongoDBCollection/MongoDBDeleteMany/MongoDBDeleteMany.js +0 -43
- package/dist/connections/MongoDBCollection/MongoDBDeleteMany/schema.js +0 -42
- package/dist/connections/MongoDBCollection/MongoDBDeleteOne/MongoDBDeleteOne.js +0 -43
- package/dist/connections/MongoDBCollection/MongoDBDeleteOne/schema.js +0 -42
- package/dist/connections/MongoDBCollection/MongoDBFind/MongoDBFind.js +0 -40
- package/dist/connections/MongoDBCollection/MongoDBFind/schema.js +0 -42
- package/dist/connections/MongoDBCollection/MongoDBFindOne/MongoDBFindOne.js +0 -39
- package/dist/connections/MongoDBCollection/MongoDBFindOne/schema.js +0 -42
- package/dist/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.js +0 -43
- package/dist/connections/MongoDBCollection/MongoDBInsertMany/schema.js +0 -48
- package/dist/connections/MongoDBCollection/MongoDBInsertOne/MongoDBInsertOne.js +0 -43
- package/dist/connections/MongoDBCollection/MongoDBInsertOne/schema.js +0 -42
- package/dist/connections/MongoDBCollection/MongoDBUpdateMany/MongoDBUpdateMany.js +0 -45
- package/dist/connections/MongoDBCollection/MongoDBUpdateMany/schema.js +0 -56
- package/dist/connections/MongoDBCollection/MongoDBUpdateOne/MongoDBUpdateOne.js +0 -45
- package/dist/connections/MongoDBCollection/MongoDBUpdateOne/schema.js +0 -56
- package/dist/connections/MongoDBCollection/getCollection.js +0 -32
- package/dist/connections/MongoDBCollection/schema.js +0 -69
- package/dist/connections/MongoDBCollection/serialize.js +0 -73
- package/dist/connections.js +0 -15
- package/dist/types.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-mongodb",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.29",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -36,28 +36,31 @@
|
|
|
36
36
|
"dist/*"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
|
-
"build": "
|
|
39
|
+
"build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
|
|
40
40
|
"clean": "rm -rf dist",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"test": "jest --coverage"
|
|
41
|
+
"prepublishOnly": "pnpm build",
|
|
42
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
45
|
+
"@lowdefy/helpers": "4.0.0-alpha.29",
|
|
47
46
|
"@next-auth/mongodb-adapter": "1.0.3",
|
|
48
47
|
"mongodb": "4.6.0",
|
|
49
48
|
"saslprep": "1.0.3"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"@lowdefy/ajv": "4.0.0-alpha.
|
|
53
|
-
"@shelf/jest-mongodb": "
|
|
51
|
+
"@lowdefy/ajv": "4.0.0-alpha.29",
|
|
52
|
+
"@shelf/jest-mongodb": "4.1.0",
|
|
54
53
|
"@swc/cli": "0.1.57",
|
|
55
54
|
"@swc/core": "1.2.194",
|
|
56
55
|
"@swc/jest": "0.2.21",
|
|
57
|
-
"jest": "28.1.0"
|
|
56
|
+
"jest": "28.1.0",
|
|
57
|
+
"jest-environment-node": "28.1.0",
|
|
58
|
+
"next-auth": "4.10.3",
|
|
59
|
+
"react": "18.1.0",
|
|
60
|
+
"react-dom": "18.1.0"
|
|
58
61
|
},
|
|
59
62
|
"publishConfig": {
|
|
60
63
|
"access": "public"
|
|
61
64
|
},
|
|
62
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "621a191ebc0a1569ee6669dc74c12f8be5a8c7f3"
|
|
63
66
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 { MongoClient } from 'mongodb';
|
|
16
|
-
import { MongoDBAdapter as NextAuthMongoDBAdapter } from '@next-auth/mongodb-adapter';
|
|
17
|
-
/*
|
|
18
|
-
Default collections are:
|
|
19
|
-
{
|
|
20
|
-
Users: "users",
|
|
21
|
-
Accounts: "accounts",
|
|
22
|
-
Sessions: "sessions",
|
|
23
|
-
VerificationTokens: "verification_tokens",
|
|
24
|
-
}
|
|
25
|
-
*/ // TODO: Docs: MongoDB database name should be in databaseUri
|
|
26
|
-
function MongoDBAdapter({ properties }) {
|
|
27
|
-
const { databaseUri , mongoDBClientOptions , collections } = properties;
|
|
28
|
-
const clientPromise = new MongoClient(databaseUri, mongoDBClientOptions).connect();
|
|
29
|
-
return NextAuthMongoDBAdapter(clientPromise, collections);
|
|
30
|
-
}
|
|
31
|
-
export default MongoDBAdapter;
|
package/dist/auth/adapters.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
function checkOutAndMerge({ pipeline , connection }) {
|
|
19
|
-
if (connection.write !== true) {
|
|
20
|
-
pipeline.forEach((stage)=>{
|
|
21
|
-
if (stage.$out != null || stage.$merge != null) {
|
|
22
|
-
throw new Error('Connection does not allow writes and aggregation pipeline contains a "$merge" or "$out" stage.');
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function MongodbAggregation({ request , connection }) {
|
|
28
|
-
const deserializedRequest = deserialize(request);
|
|
29
|
-
const { pipeline , options } = deserializedRequest;
|
|
30
|
-
checkOutAndMerge({
|
|
31
|
-
pipeline,
|
|
32
|
-
connection
|
|
33
|
-
});
|
|
34
|
-
const { collection , client } = await getCollection({
|
|
35
|
-
connection
|
|
36
|
-
});
|
|
37
|
-
let res;
|
|
38
|
-
try {
|
|
39
|
-
const cursor = await collection.aggregate(pipeline, options);
|
|
40
|
-
res = await cursor.toArray();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
await client.close();
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
await client.close();
|
|
46
|
-
return serialize(res);
|
|
47
|
-
}
|
|
48
|
-
MongodbAggregation.schema = schema;
|
|
49
|
-
MongodbAggregation.meta = {
|
|
50
|
-
checkRead: true,
|
|
51
|
-
checkWrite: false
|
|
52
|
-
};
|
|
53
|
-
export default MongodbAggregation;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBAggregation',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'pipeline'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
pipeline: {
|
|
24
|
-
type: 'array',
|
|
25
|
-
description: 'Array containing all the aggregation framework commands for the execution.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBAggregation request property "pipeline" should be an array.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
description: 'Optional settings.',
|
|
33
|
-
errorMessage: {
|
|
34
|
-
type: 'MongoDBAggregation request property "options" should be an object.'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: 'MongoDBAggregation request properties should be an object.',
|
|
40
|
-
required: 'MongoDBAggregation request should have required property "pipeline".'
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongoDBAggregation from './MongoDBAggregation/MongoDBAggregation.js';
|
|
16
|
-
import MongoDBDeleteMany from './MongoDBDeleteMany/MongoDBDeleteMany.js';
|
|
17
|
-
import MongoDBDeleteOne from './MongoDBDeleteOne/MongoDBDeleteOne.js';
|
|
18
|
-
import MongoDBFind from './MongoDBFind/MongoDBFind.js';
|
|
19
|
-
import MongoDBFindOne from './MongoDBFindOne/MongoDBFindOne.js';
|
|
20
|
-
import MongoDBInsertMany from './MongoDBInsertMany/MongoDBInsertMany.js';
|
|
21
|
-
import MongoDBInsertOne from './MongoDBInsertOne/MongoDBInsertOne.js';
|
|
22
|
-
import MongoDBUpdateMany from './MongoDBUpdateMany/MongoDBUpdateMany.js';
|
|
23
|
-
import MongoDBUpdateOne from './MongoDBUpdateOne/MongoDBUpdateOne.js';
|
|
24
|
-
import schema from './schema.js';
|
|
25
|
-
export default {
|
|
26
|
-
schema,
|
|
27
|
-
requests: {
|
|
28
|
-
MongoDBAggregation,
|
|
29
|
-
MongoDBDeleteMany,
|
|
30
|
-
MongoDBDeleteOne,
|
|
31
|
-
MongoDBFind,
|
|
32
|
-
MongoDBFindOne,
|
|
33
|
-
MongoDBInsertMany,
|
|
34
|
-
MongoDBInsertOne,
|
|
35
|
-
MongoDBUpdateMany,
|
|
36
|
-
MongoDBUpdateOne
|
|
37
|
-
}
|
|
38
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbDeleteMany({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { filter , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.deleteMany(filter, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
const { acknowledged , deletedCount } = serialize(res);
|
|
33
|
-
return {
|
|
34
|
-
acknowledged,
|
|
35
|
-
deletedCount
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
MongodbDeleteMany.schema = schema;
|
|
39
|
-
MongodbDeleteMany.meta = {
|
|
40
|
-
checkRead: false,
|
|
41
|
-
checkWrite: true
|
|
42
|
-
};
|
|
43
|
-
export default MongodbDeleteMany;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBDeleteMany',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'filter'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
filter: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'The filter used to select the document to update.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBDeleteMany request property "filter" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
description: 'Optional settings.',
|
|
33
|
-
errorMessage: {
|
|
34
|
-
type: 'MongoDBDeleteMany request property "options" should be an object.'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: 'MongoDBDeleteMany request properties should be an object.',
|
|
40
|
-
required: 'MongoDBDeleteMany request should have required property "filter".'
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbDeleteOne({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { filter , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.deleteOne(filter, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
const { acknowledged , deletedCount } = serialize(res);
|
|
33
|
-
return {
|
|
34
|
-
acknowledged,
|
|
35
|
-
deletedCount
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
MongodbDeleteOne.schema = schema;
|
|
39
|
-
MongodbDeleteOne.meta = {
|
|
40
|
-
checkRead: false,
|
|
41
|
-
checkWrite: true
|
|
42
|
-
};
|
|
43
|
-
export default MongodbDeleteOne;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBDeleteOne',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'filter'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
filter: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'The filter used to select the document to update.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBDeleteOne request property "filter" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
description: 'Optional settings.',
|
|
33
|
-
errorMessage: {
|
|
34
|
-
type: 'MongoDBDeleteOne request property "options" should be an object.'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: 'MongoDBDeleteOne request properties should be an object.',
|
|
40
|
-
required: 'MongoDBDeleteOne request should have required property "filter".'
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbFind({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { query , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
const cursor = await collection.find(query, options);
|
|
27
|
-
res = await cursor.toArray();
|
|
28
|
-
} catch (error) {
|
|
29
|
-
await client.close();
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
await client.close();
|
|
33
|
-
return serialize(res);
|
|
34
|
-
}
|
|
35
|
-
MongodbFind.schema = schema;
|
|
36
|
-
MongodbFind.meta = {
|
|
37
|
-
checkRead: true,
|
|
38
|
-
checkWrite: false
|
|
39
|
-
};
|
|
40
|
-
export default MongodbFind;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBFind',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'query'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
query: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'A MongoDB query object',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBFind request property "query" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
description: 'Optional settings.',
|
|
33
|
-
errorMessage: {
|
|
34
|
-
type: 'MongoDBFind request property "options" should be an object.'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: 'MongoDBFind request properties should be an object.',
|
|
40
|
-
required: 'MongoDBFind request should have required property "query".'
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbFindOne({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { query , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.findOne(query, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
return serialize(res);
|
|
33
|
-
}
|
|
34
|
-
MongodbFindOne.schema = schema;
|
|
35
|
-
MongodbFindOne.meta = {
|
|
36
|
-
checkRead: true,
|
|
37
|
-
checkWrite: false
|
|
38
|
-
};
|
|
39
|
-
export default MongodbFindOne;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBFindOne',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'query'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
query: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'A MongoDB query object',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBFindOne request property "query" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
description: 'Optional settings.',
|
|
33
|
-
errorMessage: {
|
|
34
|
-
type: 'MongoDBFindOne request property "options" should be an object.'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: 'MongoDBFindOne request properties should be an object.',
|
|
40
|
-
required: 'MongoDBFindOne request should have required property "query".'
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbInsertMany({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { docs , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.insertMany(docs, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
const { acknowledged , insertedCount } = serialize(res);
|
|
33
|
-
return {
|
|
34
|
-
acknowledged,
|
|
35
|
-
insertedCount
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
MongodbInsertMany.schema = schema;
|
|
39
|
-
MongodbInsertMany.meta = {
|
|
40
|
-
checkRead: false,
|
|
41
|
-
checkWrite: true
|
|
42
|
-
};
|
|
43
|
-
export default MongodbInsertMany;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBInsertMany',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'docs'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
docs: {
|
|
24
|
-
type: 'array',
|
|
25
|
-
description: 'The array of documents to be inserted.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBInsertMany request property "docs" should be an array.'
|
|
28
|
-
},
|
|
29
|
-
items: {
|
|
30
|
-
type: 'object',
|
|
31
|
-
errorMessage: {
|
|
32
|
-
type: 'MongoDBInsertMany request property "docs" should be an array of documents to insert.'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
options: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
description: 'Optional settings.',
|
|
39
|
-
errorMessage: {
|
|
40
|
-
type: 'MongoDBInsertMany request property "options" should be an object.'
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
errorMessage: {
|
|
45
|
-
type: 'MongoDBInsertMany request properties should be an object.',
|
|
46
|
-
required: 'MongoDBInsertMany request should have required property "docs".'
|
|
47
|
-
}
|
|
48
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbInsertOne({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { doc , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.insertOne(doc, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
const { acknowledged , insertedId } = serialize(res);
|
|
33
|
-
return {
|
|
34
|
-
acknowledged,
|
|
35
|
-
insertedId
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
MongodbInsertOne.schema = schema;
|
|
39
|
-
MongodbInsertOne.meta = {
|
|
40
|
-
checkRead: false,
|
|
41
|
-
checkWrite: true
|
|
42
|
-
};
|
|
43
|
-
export default MongodbInsertOne;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBInsertOne',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'doc'
|
|
21
|
-
],
|
|
22
|
-
properties: {
|
|
23
|
-
doc: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
description: 'The document to be inserted.',
|
|
26
|
-
errorMessage: {
|
|
27
|
-
type: 'MongoDBInsertOne request property "doc" should be an object.'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
options: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
description: 'Optional settings.',
|
|
33
|
-
errorMessage: {
|
|
34
|
-
type: 'MongoDBInsertOne request property "options" should be an object.'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: 'MongoDBInsertOne request properties should be an object.',
|
|
40
|
-
required: 'MongoDBInsertOne request should have required property "doc".'
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbUpdateMany({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { filter , update , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.updateMany(filter, update, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
const { modifiedCount , upsertedId , upsertedCount , matchedCount } = serialize(res);
|
|
33
|
-
return {
|
|
34
|
-
modifiedCount,
|
|
35
|
-
upsertedId,
|
|
36
|
-
upsertedCount,
|
|
37
|
-
matchedCount
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
MongodbUpdateMany.schema = schema;
|
|
41
|
-
MongodbUpdateMany.meta = {
|
|
42
|
-
checkRead: false,
|
|
43
|
-
checkWrite: true
|
|
44
|
-
};
|
|
45
|
-
export default MongodbUpdateMany;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBUpdateMany',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'filter',
|
|
21
|
-
'update'
|
|
22
|
-
],
|
|
23
|
-
properties: {
|
|
24
|
-
filter: {
|
|
25
|
-
type: 'object',
|
|
26
|
-
description: 'The filter used to select the documents to update.',
|
|
27
|
-
errorMessage: {
|
|
28
|
-
type: 'MongoDBUpdateMany request property "filter" should be an object.'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
update: {
|
|
32
|
-
type: [
|
|
33
|
-
'object',
|
|
34
|
-
'array'
|
|
35
|
-
],
|
|
36
|
-
description: 'The update operations to be applied to the documents.',
|
|
37
|
-
errorMessage: {
|
|
38
|
-
type: 'MongoDBUpdateMany request property "update" should be an object.'
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
options: {
|
|
42
|
-
type: 'object',
|
|
43
|
-
description: 'Optional settings.',
|
|
44
|
-
errorMessage: {
|
|
45
|
-
type: 'MongoDBUpdateMany request property "options" should be an object.'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
errorMessage: {
|
|
50
|
-
type: 'MongoDBUpdateMany request properties should be an object.',
|
|
51
|
-
required: {
|
|
52
|
-
filter: 'MongoDBUpdateMany request should have required property "filter".',
|
|
53
|
-
update: 'MongoDBUpdateMany request should have required property "update".'
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 MongodbUpdateOne({ request , connection }) {
|
|
19
|
-
const deserializedRequest = deserialize(request);
|
|
20
|
-
const { filter , update , options } = deserializedRequest;
|
|
21
|
-
const { collection , client } = await getCollection({
|
|
22
|
-
connection
|
|
23
|
-
});
|
|
24
|
-
let res;
|
|
25
|
-
try {
|
|
26
|
-
res = await collection.updateOne(filter, update, options);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
await client.close();
|
|
32
|
-
const { modifiedCount , upsertedId , upsertedCount , matchedCount } = serialize(res);
|
|
33
|
-
return {
|
|
34
|
-
modifiedCount,
|
|
35
|
-
upsertedId,
|
|
36
|
-
upsertedCount,
|
|
37
|
-
matchedCount
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
MongodbUpdateOne.schema = schema;
|
|
41
|
-
MongodbUpdateOne.meta = {
|
|
42
|
-
checkRead: false,
|
|
43
|
-
checkWrite: true
|
|
44
|
-
};
|
|
45
|
-
export default MongodbUpdateOne;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - MongoDBUpdateOne',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'filter',
|
|
21
|
-
'update'
|
|
22
|
-
],
|
|
23
|
-
properties: {
|
|
24
|
-
filter: {
|
|
25
|
-
type: 'object',
|
|
26
|
-
description: 'The filter used to select the document to update.',
|
|
27
|
-
errorMessage: {
|
|
28
|
-
type: 'MongoDBUpdateOne request property "filter" should be an object.'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
update: {
|
|
32
|
-
type: [
|
|
33
|
-
'object',
|
|
34
|
-
'array'
|
|
35
|
-
],
|
|
36
|
-
description: 'The update operations to be applied to the document.',
|
|
37
|
-
errorMessage: {
|
|
38
|
-
type: 'MongoDBUpdateOne request property "update" should be an object.'
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
options: {
|
|
42
|
-
type: 'object',
|
|
43
|
-
description: 'Optional settings.',
|
|
44
|
-
errorMessage: {
|
|
45
|
-
type: 'MongoDBUpdateOne request property "options" should be an object.'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
errorMessage: {
|
|
50
|
-
type: 'MongoDBUpdateOne request properties should be an object.',
|
|
51
|
-
required: {
|
|
52
|
-
filter: 'MongoDBUpdateOne request should have required property "filter".',
|
|
53
|
-
update: 'MongoDBUpdateOne request should have required property "update".'
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 { MongoClient } from 'mongodb';
|
|
16
|
-
async function getCollection({ connection }) {
|
|
17
|
-
let client;
|
|
18
|
-
const { collection , databaseUri , databaseName , options } = connection;
|
|
19
|
-
client = new MongoClient(databaseUri, options);
|
|
20
|
-
await client.connect();
|
|
21
|
-
try {
|
|
22
|
-
const db = client.db(databaseName);
|
|
23
|
-
return {
|
|
24
|
-
client,
|
|
25
|
-
collection: db.collection(collection)
|
|
26
|
-
};
|
|
27
|
-
} catch (error) {
|
|
28
|
-
await client.close();
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export default getCollection;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Connection Schema - MongoDBCollection',
|
|
18
|
-
type: 'object',
|
|
19
|
-
required: [
|
|
20
|
-
'databaseUri',
|
|
21
|
-
'collection'
|
|
22
|
-
],
|
|
23
|
-
properties: {
|
|
24
|
-
databaseUri: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
description: 'Connection uri string for the MongoDb deployment.',
|
|
27
|
-
errorMessage: {
|
|
28
|
-
type: 'MongoDBCollection connection property "databaseUri" should be a string.'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
databaseName: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
description: 'AWS IAM secret access key with s3 access.',
|
|
34
|
-
errorMessage: {
|
|
35
|
-
type: 'MongoDBCollection connection property "databaseName" should be a string.'
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
collection: {
|
|
39
|
-
type: 'string',
|
|
40
|
-
description: 'AWS region the bucket is located in.',
|
|
41
|
-
errorMessage: {
|
|
42
|
-
type: 'MongoDBCollection connection property "collection" should be a string.'
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
read: {
|
|
46
|
-
type: 'boolean',
|
|
47
|
-
default: true,
|
|
48
|
-
description: 'Allow reads from the collection.',
|
|
49
|
-
errorMessage: {
|
|
50
|
-
type: 'MongoDBCollection connection property "read" should be a boolean.'
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
write: {
|
|
54
|
-
type: 'boolean',
|
|
55
|
-
default: false,
|
|
56
|
-
description: 'Allow writes to the collection.',
|
|
57
|
-
errorMessage: {
|
|
58
|
-
type: 'MongoDBCollection connection property "write" should be a boolean.'
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
errorMessage: {
|
|
63
|
-
type: 'MongoDBCollection connection properties should be an object.',
|
|
64
|
-
required: {
|
|
65
|
-
databaseUri: 'MongoDBCollection connection should have required property "databaseUri".',
|
|
66
|
-
collection: 'MongoDBCollection connection should have required property "collection".'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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 { ObjectId } from 'mongodb';
|
|
16
|
-
import { type } from '@lowdefy/helpers';
|
|
17
|
-
function replacer(_, value) {
|
|
18
|
-
if (type.isObject(value)) {
|
|
19
|
-
Object.keys(value).forEach((key)=>{
|
|
20
|
-
if (value[key] instanceof ObjectId) {
|
|
21
|
-
// eslint-disable-next-line no-param-reassign
|
|
22
|
-
value[key] = {
|
|
23
|
-
_oid: value[key].toHexString()
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (type.isDate(value[key])) {
|
|
27
|
-
// eslint-disable-next-line no-param-reassign
|
|
28
|
-
value[key] = {
|
|
29
|
-
_date: value[key].valueOf()
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
if (type.isArray(value)) {
|
|
36
|
-
return value.map((item)=>{
|
|
37
|
-
if (item instanceof ObjectId) {
|
|
38
|
-
return {
|
|
39
|
-
_oid: item.toHexString()
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (type.isDate(item)) {
|
|
43
|
-
return {
|
|
44
|
-
_date: item.valueOf()
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return item;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
function reviver(key, value) {
|
|
53
|
-
if (type.isObject(value)) {
|
|
54
|
-
if (value._oid) {
|
|
55
|
-
return ObjectId.createFromHexString(value._oid);
|
|
56
|
-
}
|
|
57
|
-
if (type.isInt(value._date) || type.isString(value._date)) {
|
|
58
|
-
return new Date(value._date);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
function serialize(obj) {
|
|
64
|
-
if (type.isUndefined(obj)) return obj;
|
|
65
|
-
return JSON.parse(JSON.stringify(obj, replacer));
|
|
66
|
-
}
|
|
67
|
-
// need to use replacer here, since objects are already partially deserialised.
|
|
68
|
-
// otherwise dates become strings
|
|
69
|
-
function deserialize(obj) {
|
|
70
|
-
if (type.isUndefined(obj)) return obj;
|
|
71
|
-
return JSON.parse(JSON.stringify(obj, replacer), reviver);
|
|
72
|
-
}
|
|
73
|
-
export { serialize, deserialize };
|
package/dist/connections.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 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
|
-
*/ export { default as MongoDBCollection } from './connections/MongoDBCollection/MongoDBCollection.js';
|
package/dist/types.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/namespace */ /*
|
|
2
|
-
Copyright 2020-2022 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 * as adapters from './auth/adapters.js';
|
|
16
|
-
import * as connections from './connections.js';
|
|
17
|
-
export default {
|
|
18
|
-
auth: {
|
|
19
|
-
adapters: Object.keys(adapters)
|
|
20
|
-
},
|
|
21
|
-
connections: Object.keys(connections),
|
|
22
|
-
requests: Object.keys(connections).map((connection)=>Object.keys(connections[connection].requests)).flat()
|
|
23
|
-
};
|