Skip to content

Commit

Permalink
Merge pull request #31 from lowdefy/mongodb-fix
Browse files Browse the repository at this point in the history
Export additional types on connection to include log collection
  • Loading branch information
SamTolmay authored Nov 17, 2023
2 parents eaf0953 + 572cd7a commit f7285bf
Show file tree
Hide file tree
Showing 17 changed files with 1,147 additions and 1,119 deletions.
6 changes: 6 additions & 0 deletions .changeset/eight-shoes-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@lowdefy/community-plugin-mongodb': patch
---

Add connectionId to log-changes logs.
Fix: Request plugins were not exported as part of package.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@

import { MongoDBCollection } from '@lowdefy/connection-mongodb/connections';

import MongoDBDeleteMany from './MongoDBDeleteMany/MongoDBDeleteMany.js';
import MongoDBDeleteOne from './MongoDBDeleteOne/MongoDBDeleteOne.js';
import MongoDBInsertConsecutiveId from './MongoDBInsertConsecutiveId/MongoDBInsertConsecutiveId.js';
import MongoDBInsertMany from './MongoDBInsertMany/MongoDBInsertMany.js';
import MongoDBInsertManyConsecutiveIds from './MongoDBInsertManyConsecutiveIds/MongoDBInsertManyConsecutiveIds.js';
import MongoDBInsertOne from './MongoDBInsertOne/MongoDBInsertOne.js';
import MongoDBUpdateMany from './MongoDBUpdateMany/MongoDBUpdateMany.js';
import MongoDBUpdateOne from './MongoDBUpdateOne/MongoDBUpdateOne.js';
import schema from './schema.js';

const { requests } = MongoDBCollection;
Expand All @@ -26,7 +32,13 @@ export default {
schema,
requests: {
...requests,
MongoDBDeleteMany,
MongoDBDeleteOne,
MongoDBInsertConsecutiveId,
MongoDBInsertMany,
MongoDBInsertManyConsecutiveIds,
MongoDBInsertOne,
MongoDBUpdateMany,
MongoDBUpdateOne,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import getCollection from '../getCollection.js';
import { serialize, deserialize } from '../serialize.js';
import schema from './schema.js';

async function MongodbDeleteMany({ blockId, connection, pageId, request, requestId, payload }) {
async function MongodbDeleteMany({
blockId,
connection,
connectionId,
pageId,
request,
requestId,
payload,
}) {
const deserializedRequest = deserialize(request);
const { filter, options } = deserializedRequest;
const { collection, client, logCollection } = await getCollection({ connection });
Expand All @@ -29,6 +37,7 @@ async function MongodbDeleteMany({ blockId, connection, pageId, request, request
await logCollection.insertOne({
args: { filter, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test('deleteMany logCollection - Single Document', async () => {
const res = await MongoDBDeleteMany({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteMany_log',
Expand All @@ -93,6 +94,7 @@ test('deleteMany logCollection - Single Document', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteMany_log',
Expand Down Expand Up @@ -132,6 +134,7 @@ test('deleteMany logCollection - Multiple Documents', async () => {
const res = await MongoDBDeleteMany({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteMany_multiple',
Expand All @@ -147,6 +150,7 @@ test('deleteMany logCollection - Multiple Documents', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteMany_multiple',
Expand Down Expand Up @@ -186,6 +190,7 @@ test('deleteMany logCollection - Multiple Documents one field', async () => {
const res = await MongoDBDeleteMany({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteMany_multiple_one_field',
Expand All @@ -201,6 +206,7 @@ test('deleteMany logCollection - Multiple Documents one field', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteMany_multiple_one_field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import getCollection from '../getCollection.js';
import { serialize, deserialize } from '../serialize.js';
import schema from './schema.js';

async function MongodbDeleteOne({ blockId, connection, pageId, request, requestId, payload }) {
async function MongodbDeleteOne({
blockId,
connection,
connectionId,
pageId,
request,
requestId,
payload,
}) {
const deserializedRequest = deserialize(request);
const { filter, options } = deserializedRequest;
const { collection, client, logCollection } = await getCollection({ connection });
Expand All @@ -30,6 +38,7 @@ async function MongodbDeleteOne({ blockId, connection, pageId, request, requestI
await logCollection.insertOne({
args: { filter, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ test('deleteOne logCollection', async () => {
const res = await MongoDBDeleteOne({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteOne_log',
Expand All @@ -80,6 +81,7 @@ test('deleteOne logCollection', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'deleteOne_log',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async function insertDocument({
blockId,
connection,
collection,
connectionId,
doc,
logCollection,
options,
Expand All @@ -36,6 +37,7 @@ async function insertDocument({
{
args: { doc, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import getCollection from '../getCollection.js';
import { serialize, deserialize } from '../serialize.js';
import schema from './schema.js';

async function MongodbInsertMany({ blockId, connection, pageId, request, requestId, payload }) {
async function MongodbInsertMany({
blockId,
connection,
connectionId,
pageId,
request,
requestId,
payload,
}) {
const deserializedRequest = deserialize(request);
const { docs, options } = deserializedRequest;
const { collection, client, logCollection } = await getCollection({ connection });
Expand All @@ -29,6 +37,7 @@ async function MongodbInsertMany({ blockId, connection, pageId, request, request
await logCollection.insertOne({
args: { docs, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test('insertMany logCollection', async () => {
const res = await MongoDBInsertMany({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertMany_log',
Expand All @@ -81,6 +82,7 @@ test('insertMany logCollection', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertMany_log',
Expand Down Expand Up @@ -122,6 +124,7 @@ test('insertMany logCollection options', async () => {
const res = await MongoDBInsertMany({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertMany_options_log',
Expand All @@ -137,6 +140,7 @@ test('insertMany logCollection options', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertMany_options_log',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import schema from './schema.js';
async function insertDocuments({
blockId,
connection,
connectionId,
collection,
docs,
logCollection,
Expand All @@ -36,6 +37,7 @@ async function insertDocuments({
{
args: { docs, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import getCollection from '../getCollection.js';
import { serialize, deserialize } from '../serialize.js';
import schema from './schema.js';

async function MongodbInsertOne({ blockId, connection, pageId, request, requestId, payload }) {
async function MongodbInsertOne({
blockId,
connection,
connectionId,
pageId,
request,
requestId,
payload,
}) {
const deserializedRequest = deserialize(request);
const { doc, options } = deserializedRequest;
const { collection, client, logCollection } = await getCollection({ connection });
Expand All @@ -29,6 +37,7 @@ async function MongodbInsertOne({ blockId, connection, pageId, request, requestI
await logCollection.insertOne({
args: { doc, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ test('insertOne logCollection', async () => {
const res = await MongoDBInsertOne({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertOne_log',
Expand All @@ -74,6 +75,7 @@ test('insertOne logCollection', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertOne_log',
Expand Down Expand Up @@ -115,6 +117,7 @@ test('insertOne logCollection options', async () => {
const res = await MongoDBInsertOne({
request,
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertOne_options_log',
Expand All @@ -130,6 +133,7 @@ test('insertOne logCollection options', async () => {
});
expect(logged).toMatchObject({
blockId: 'blockId',
connectionId: 'connectionId',
pageId: 'pageId',
payload: { payload: true },
requestId: 'insertOne_options_log',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ import getCollection from '../getCollection.js';
import { serialize, deserialize } from '../serialize.js';
import schema from './schema.js';

async function MongodbUpdateMany({ blockId, connection, pageId, request, requestId, payload }) {
async function MongodbUpdateMany({
blockId,
connection,
connectionId,
pageId,
request,
requestId,
payload,
}) {
const deserializedRequest = deserialize(request);
const { filter, update, options } = deserializedRequest;
const { collection, client, logCollection } = await getCollection({ connection });
Expand All @@ -29,6 +37,7 @@ async function MongodbUpdateMany({ blockId, connection, pageId, request, request
await logCollection.insertOne({
args: { filter, update, options },
blockId,
connectionId,
pageId,
payload,
requestId,
Expand Down
Loading

0 comments on commit f7285bf

Please sign in to comment.