@lowdefy/connection-mongodb 4.0.0-rc.10 → 4.0.0-rc.11

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.
@@ -15,31 +15,15 @@
15
15
  */ import getCollection from '../getCollection.js';
16
16
  import { serialize, deserialize } from '../serialize.js';
17
17
  import schema from './schema.js';
18
- async function MongodbDeleteMany({ blockId, connection, pageId, request, requestId, payload }) {
18
+ async function MongodbDeleteMany({ connection, request }) {
19
19
  const deserializedRequest = deserialize(request);
20
20
  const { filter, options } = deserializedRequest;
21
- const { collection, client, logCollection } = await getCollection({
21
+ const { collection, client } = await getCollection({
22
22
  connection
23
23
  });
24
24
  let response;
25
25
  try {
26
26
  response = await collection.deleteMany(filter, options);
27
- if (logCollection) {
28
- await logCollection.insertOne({
29
- args: {
30
- filter,
31
- options
32
- },
33
- blockId,
34
- pageId,
35
- payload,
36
- requestId,
37
- response,
38
- timestamp: new Date(),
39
- type: 'MongoDBDeleteMany',
40
- meta: connection.changeLog?.meta
41
- });
42
- }
43
27
  } catch (error) {
44
28
  await client.close();
45
29
  throw error;
@@ -15,34 +15,15 @@
15
15
  */ import getCollection from '../getCollection.js';
16
16
  import { serialize, deserialize } from '../serialize.js';
17
17
  import schema from './schema.js';
18
- async function MongodbDeleteOne({ blockId, connection, pageId, request, requestId, payload }) {
18
+ async function MongodbDeleteOne({ connection, request }) {
19
19
  const deserializedRequest = deserialize(request);
20
20
  const { filter, options } = deserializedRequest;
21
- const { collection, client, logCollection } = await getCollection({
21
+ const { collection, client } = await getCollection({
22
22
  connection
23
23
  });
24
24
  let response;
25
25
  try {
26
- if (logCollection) {
27
- const { value, ...responseWithoutValue } = await collection.findOneAndDelete(filter, options);
28
- response = responseWithoutValue;
29
- await logCollection.insertOne({
30
- args: {
31
- filter,
32
- options
33
- },
34
- blockId,
35
- pageId,
36
- payload,
37
- requestId,
38
- before: value,
39
- timestamp: new Date(),
40
- type: 'MongoDBDeleteOne',
41
- meta: connection.changeLog?.meta
42
- });
43
- } else {
44
- response = await collection.deleteOne(filter, options);
45
- }
26
+ response = await collection.deleteOne(filter, options);
46
27
  } catch (error) {
47
28
  await client.close();
48
29
  throw error;
@@ -15,31 +15,15 @@
15
15
  */ import getCollection from '../getCollection.js';
16
16
  import { serialize, deserialize } from '../serialize.js';
17
17
  import schema from './schema.js';
18
- async function MongodbInsertMany({ blockId, connection, pageId, request, requestId, payload }) {
18
+ async function MongodbInsertMany({ connection, request }) {
19
19
  const deserializedRequest = deserialize(request);
20
20
  const { docs, options } = deserializedRequest;
21
- const { collection, client, logCollection } = await getCollection({
21
+ const { collection, client } = await getCollection({
22
22
  connection
23
23
  });
24
24
  let response;
25
25
  try {
26
26
  response = await collection.insertMany(docs, options);
27
- if (logCollection) {
28
- await logCollection.insertOne({
29
- args: {
30
- docs,
31
- options
32
- },
33
- blockId,
34
- pageId,
35
- payload,
36
- requestId,
37
- response,
38
- timestamp: new Date(),
39
- type: 'MongoDBInsertMany',
40
- meta: connection.changeLog?.meta
41
- });
42
- }
43
27
  } catch (error) {
44
28
  await client.close();
45
29
  throw error;
@@ -15,31 +15,15 @@
15
15
  */ import getCollection from '../getCollection.js';
16
16
  import { serialize, deserialize } from '../serialize.js';
17
17
  import schema from './schema.js';
18
- async function MongodbInsertOne({ blockId, connection, pageId, request, requestId, payload }) {
18
+ async function MongodbInsertOne({ connection, request }) {
19
19
  const deserializedRequest = deserialize(request);
20
20
  const { doc, options } = deserializedRequest;
21
- const { collection, client, logCollection } = await getCollection({
21
+ const { collection, client } = await getCollection({
22
22
  connection
23
23
  });
24
24
  let response;
25
25
  try {
26
26
  response = await collection.insertOne(doc, options);
27
- if (logCollection) {
28
- await logCollection.insertOne({
29
- args: {
30
- doc,
31
- options
32
- },
33
- blockId,
34
- pageId,
35
- payload,
36
- requestId,
37
- response,
38
- timestamp: new Date(),
39
- type: 'MongoDBInsertOne',
40
- meta: connection.changeLog?.meta
41
- });
42
- }
43
27
  } catch (error) {
44
28
  await client.close();
45
29
  throw error;
@@ -15,32 +15,15 @@
15
15
  */ import getCollection from '../getCollection.js';
16
16
  import { serialize, deserialize } from '../serialize.js';
17
17
  import schema from './schema.js';
18
- async function MongodbUpdateMany({ blockId, connection, pageId, request, requestId, payload }) {
18
+ async function MongodbUpdateMany({ connection, request }) {
19
19
  const deserializedRequest = deserialize(request);
20
20
  const { filter, update, options } = deserializedRequest;
21
- const { collection, client, logCollection } = await getCollection({
21
+ const { collection, client } = await getCollection({
22
22
  connection
23
23
  });
24
24
  let response;
25
25
  try {
26
26
  response = await collection.updateMany(filter, update, options);
27
- if (logCollection) {
28
- await logCollection.insertOne({
29
- args: {
30
- filter,
31
- update,
32
- options
33
- },
34
- blockId,
35
- pageId,
36
- payload,
37
- requestId,
38
- response,
39
- timestamp: new Date(),
40
- type: 'MongoDBUpdateMany',
41
- meta: connection.changeLog?.meta
42
- });
43
- }
44
27
  } catch (error) {
45
28
  await client.close();
46
29
  throw error;
@@ -15,39 +15,15 @@
15
15
  */ import getCollection from '../getCollection.js';
16
16
  import { serialize, deserialize } from '../serialize.js';
17
17
  import schema from './schema.js';
18
- async function MongodbUpdateOne({ blockId, connection, pageId, request, requestId, payload }) {
18
+ async function MongodbUpdateOne({ connection, request }) {
19
19
  const deserializedRequest = deserialize(request);
20
20
  const { filter, update, options } = deserializedRequest;
21
- const { collection, client, logCollection } = await getCollection({
21
+ const { collection, client } = await getCollection({
22
22
  connection
23
23
  });
24
24
  let response;
25
25
  try {
26
- if (logCollection) {
27
- const { value, ...responseWithoutValue } = await collection.findOneAndUpdate(filter, update, options);
28
- response = responseWithoutValue;
29
- const after = await collection.findOne({
30
- _id: value ? value._id : response.lastErrorObject?.upserted
31
- });
32
- await logCollection.insertOne({
33
- args: {
34
- filter,
35
- update,
36
- options
37
- },
38
- blockId,
39
- pageId,
40
- payload,
41
- requestId,
42
- before: value,
43
- after,
44
- timestamp: new Date(),
45
- type: 'MongoDBUpdateOne',
46
- meta: connection.changeLog?.meta
47
- });
48
- } else {
49
- response = await collection.updateOne(filter, update, options);
50
- }
26
+ response = await collection.updateOne(filter, update, options);
51
27
  } catch (error) {
52
28
  await client.close();
53
29
  throw error;
@@ -15,15 +15,14 @@
15
15
  */ import { MongoClient } from 'mongodb';
16
16
  async function getCollection({ connection }) {
17
17
  let client;
18
- const { collection, databaseName, databaseUri, changeLog, options } = connection;
18
+ const { collection, databaseName, databaseUri, options } = connection;
19
19
  client = new MongoClient(databaseUri, options);
20
20
  await client.connect();
21
21
  try {
22
22
  const db = client.db(databaseName);
23
23
  return {
24
24
  client,
25
- collection: db.collection(collection),
26
- logCollection: changeLog?.collection && db.collection(changeLog.collection)
25
+ collection: db.collection(collection)
27
26
  };
28
27
  } catch (error) {
29
28
  await client.close();
@@ -30,14 +30,14 @@
30
30
  },
31
31
  databaseName: {
32
32
  type: 'string',
33
- description: 'AWS IAM secret access key with s3 access.',
33
+ description: 'Database name.',
34
34
  errorMessage: {
35
35
  type: 'MongoDBCollection connection property "databaseName" should be a string.'
36
36
  }
37
37
  },
38
38
  collection: {
39
39
  type: 'string',
40
- description: 'AWS region the bucket is located in.',
40
+ description: 'Collection name.',
41
41
  errorMessage: {
42
42
  type: 'MongoDBCollection connection property "collection" should be a string.'
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/connection-mongodb",
3
- "version": "4.0.0-rc.10",
3
+ "version": "4.0.0-rc.11",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,26 +42,26 @@
42
42
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
43
43
  },
44
44
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-rc.10",
46
- "@next-auth/mongodb-adapter": "1.1.1",
45
+ "@lowdefy/helpers": "4.0.0-rc.11",
46
+ "@next-auth/mongodb-adapter": "1.1.3",
47
47
  "mongodb": "4.13.0",
48
48
  "saslprep": "1.0.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@lowdefy/ajv": "4.0.0-rc.10",
52
- "@shelf/jest-mongodb": "4.1.4",
51
+ "@lowdefy/ajv": "4.0.0-rc.11",
52
+ "@shelf/jest-mongodb": "4.1.7",
53
53
  "@swc/cli": "0.1.62",
54
- "@swc/core": "1.3.70",
55
- "@swc/jest": "0.2.27",
54
+ "@swc/core": "1.3.92",
55
+ "@swc/jest": "0.2.29",
56
56
  "jest": "28.1.3",
57
57
  "jest-environment-node": "28.1.3",
58
- "next": "12.3.4",
59
- "next-auth": "4.20.1",
58
+ "next": "13.5.4",
59
+ "next-auth": "4.23.2",
60
60
  "react": "18.2.0",
61
61
  "react-dom": "18.2.0"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
66
+ "gitHead": "dbc49d3688a6d2f44de25cc3f4bc071627f7ebfa"
67
67
  }