mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(MongoDB Node): Stringify response ObjectIDs (#6990)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
@@ -6,15 +6,15 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
import { ObjectId } from 'mongodb';
|
||||
import type {
|
||||
IMongoCredentials,
|
||||
IMongoCredentialsType,
|
||||
IMongoParametricCredentials,
|
||||
} from './mongoDb.types';
|
||||
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
|
||||
/**
|
||||
* Standard way of building the MongoDB connection string, unless overridden with a provided string
|
||||
*
|
||||
@@ -129,3 +129,14 @@ export function prepareFields(fields: string) {
|
||||
.map((field) => field.trim())
|
||||
.filter((field) => !!field);
|
||||
}
|
||||
|
||||
export function stringifyObjectIDs(items: IDataObject[]) {
|
||||
items.forEach((item) => {
|
||||
if (item._id instanceof ObjectId) {
|
||||
item._id = item._id.toString();
|
||||
}
|
||||
if (item.id instanceof ObjectId) {
|
||||
item.id = item.id.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user