n8n/packages/nodes-base/nodes/MongoDb/mongo.node.options.ts
Iván Ovejero 59f2e8e7d5
refactor: Apply more eslint-plugin-n8n-nodes-base rules (#3624)
* ⬆️ Upgrade `eslint-plugin-n8n-nodes-base`

* 📦 Update `package-lock.json`

* 🔧 Adjust renamed filesystem rules

* ✏️ Alphabetize ruleset

*  Categorize overrides

*  Set renamings in lint exceptions

*  Run baseline `lintfix`

*  Update linting scripts

* 👕 Apply `node-param-description-missing-from-dynamic-multi-options`

* 👕 Apply `cred-class-field-name-missing-oauth2` (#3627)

* Rule working as intended

* Removed comments

* Move cred rule to different rule set

* 👕 Apply `node-param-array-type-assertion`

* 👕 Apply `node-dirname-against-convention`

* Apply `cred-class-field-display-name-oauth2` (#3628)

* Apply `node-execute-block-wrong-error-thrown`

* Apply `node-class-description-display-name-unsuffixed-trigger-node`

* Apply `node-class-description-name-unsuffixed-trigger-node`

* Apply `cred-class-name-missing-oauth2-suffix` (#3636)

* Rule working as intended, add exception to existing nodes

* 👕 Apply `cred-class-field-name-uppercase-first-char` (#3638)

* ⬆️ Upgrade to plugin version 1.2.28

* 📦 Update `package-lock.json`

* 👕 Update lintings with 1.2.8 change

* 👕 Apply `cred-class-field-name-unsuffixed`

* 👕 Apply `cred-class-name-unsuffixed`

* 👕 Apply `node-class-description-credentials-name-unsuffixed`

* ✏️ Alphabetize rules

*  Remove `nodelinter` package

* 📦 Update `package-lock.json`

*  Consolidate `lint` and `lintfix` scripts

Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
Co-authored-by: agobrech <ael.gobrecht@gmail.com>
2022-07-04 11:12:08 +02:00

284 lines
5.8 KiB
TypeScript

/* eslint-disable n8n-nodes-base/node-filename-against-convention */
import {
INodeTypeDescription,
} from 'n8n-workflow';
/**
* Options to be displayed
*/
export const nodeDescription: INodeTypeDescription = {
displayName: 'MongoDB',
name: 'mongoDb',
icon: 'file:mongodb.svg',
group: ['input'],
version: 1,
description: 'Find, insert and update documents in MongoDB',
defaults: {
name: 'MongoDB',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'mongoDb',
required: true,
},
],
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Aggregate',
value: 'aggregate',
description: 'Aggregate documents',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete documents',
},
{
name: 'Find',
value: 'find',
description: 'Find documents',
},
{
name: 'Insert',
value: 'insert',
description: 'Insert documents',
},
{
name: 'Update',
value: 'update',
description: 'Update documents',
},
],
default: 'find',
},
{
displayName: 'Collection',
name: 'collection',
type: 'string',
required: true,
default: '',
description: 'MongoDB Collection',
},
// ----------------------------------
// aggregate
// ----------------------------------
{
displayName: 'Query',
name: 'query',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
operation: [
'aggregate',
],
},
},
default: '',
placeholder: `[{ "$match": { "$gt": "1950-01-01" }, ... }]`,
hint: 'Learn more about aggregation pipeline <a href="https://docs.mongodb.com/manual/core/aggregation-pipeline/">here</a>',
required: true,
description: 'MongoDB aggregation pipeline query in JSON format',
},
// ----------------------------------
// delete
// ----------------------------------
{
displayName: 'Delete Query (JSON Format)',
name: 'query',
type: 'json',
typeOptions: {
rows: 5,
},
displayOptions: {
show: {
operation: [
'delete',
],
},
},
default: '{}',
placeholder: `{ "birth": { "$gt": "1950-01-01" } }`,
required: true,
description: 'MongoDB Delete query',
},
// ----------------------------------
// find
// ----------------------------------
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: ['find'],
},
},
default: {},
placeholder: 'Add options',
description: 'Add query options',
options: [
{
displayName: 'Limit',
name: 'limit',
type: 'number',
typeOptions: {
minValue: 1,
},
default: 0,
// eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-limit
description: 'Use limit to specify the maximum number of documents or 0 for unlimited documents',
},
{
displayName: 'Skip',
name: 'skip',
type: 'number',
default: 0,
description: 'The number of documents to skip in the results set',
},
{
displayName: 'Sort (JSON Format)',
name: 'sort',
type: 'json',
typeOptions: {
rows: 2,
},
default: '{}',
placeholder: '{ "field": -1 }',
description: 'A JSON that defines the sort order of the result set',
},
],
},
{
displayName: 'Query (JSON Format)',
name: 'query',
type: 'json',
typeOptions: {
rows: 5,
},
displayOptions: {
show: {
operation: [
'find',
],
},
},
default: '{}',
placeholder: `{ "birth": { "$gt": "1950-01-01" } }`,
required: true,
description: 'MongoDB Find query',
},
// ----------------------------------
// insert
// ----------------------------------
{
displayName: 'Fields',
name: 'fields',
type: 'string',
displayOptions: {
show: {
operation: [
'insert',
],
},
},
default: '',
placeholder: 'name,description',
description: 'Comma-separated list of the fields to be included into the new document',
},
// ----------------------------------
// update
// ----------------------------------
{
displayName: 'Update Key',
name: 'updateKey',
type: 'string',
displayOptions: {
show: {
operation: [
'update',
],
},
},
default: 'id',
required: true,
// eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id
description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
displayOptions: {
show: {
operation: [
'update',
],
},
},
default: '',
placeholder: 'name,description',
description: 'Comma-separated list of the fields to be included into the new document',
},
{
displayName: 'Upsert',
name: 'upsert',
type: 'boolean',
displayOptions: {
show: {
operation: ['update'],
},
},
default: false,
description: 'Whether to perform an insert if no documents match the update key',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: [
'update',
'insert',
],
},
},
placeholder: 'Add Option',
default: {},
options: [
{
displayName: 'Date Fields',
name: 'dateFields',
type: 'string',
default: '',
description: 'Comma separeted list of fields that will be parse as Mongo Date type',
},
{
displayName:'Use Dot Notation',
name: 'useDotNotation',
type: 'boolean',
default: false,
description: 'Whether to use dot notation to access date fields',
},
],
},
],
};