2020-04-06 11:04:59 -07:00
|
|
|
import { INodeTypeDescription } from 'n8n-workflow';
|
2020-04-05 18:06:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Options to be displayed
|
|
|
|
*/
|
|
|
|
export const nodeDescription: INodeTypeDescription = {
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'MongoDB',
|
|
|
|
name: 'mongoDb',
|
|
|
|
icon: 'file:mongoDb.png',
|
|
|
|
group: ['input'],
|
2020-04-05 18:06:00 -07:00
|
|
|
version: 1,
|
2020-04-06 11:04:59 -07:00
|
|
|
description: 'Find, insert and update documents in MongoDB.',
|
2020-04-05 18:06:00 -07:00
|
|
|
defaults: {
|
2020-04-06 11:04:59 -07:00
|
|
|
name: 'MongoDB',
|
|
|
|
color: '#13AA52'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
2020-04-06 11:04:59 -07:00
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
2020-04-05 18:06:00 -07:00
|
|
|
credentials: [
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
name: 'mongoDb',
|
|
|
|
required: true
|
|
|
|
}
|
2020-04-05 18:06:00 -07:00
|
|
|
],
|
|
|
|
properties: [
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
2020-04-05 18:06:00 -07:00
|
|
|
options: [
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
name: 'Find',
|
|
|
|
value: 'find',
|
|
|
|
description: 'Find documents.'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
name: 'Insert',
|
|
|
|
value: 'insert',
|
|
|
|
description: 'Insert documents.'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
|
|
|
description: 'Updates documents.'
|
|
|
|
}
|
2020-04-05 18:06:00 -07:00
|
|
|
],
|
2020-04-06 11:04:59 -07:00
|
|
|
default: 'find',
|
|
|
|
description: 'The operation to perform.'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'Collection',
|
|
|
|
name: 'collection',
|
|
|
|
type: 'string',
|
2020-04-05 18:06:00 -07:00
|
|
|
required: true,
|
2020-04-06 11:04:59 -07:00
|
|
|
default: '',
|
|
|
|
description: 'MongoDB Collection'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// find
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'Query (JSON format)',
|
|
|
|
name: 'query',
|
|
|
|
type: 'string',
|
2020-04-05 18:06:00 -07:00
|
|
|
typeOptions: {
|
2020-04-06 11:04:59 -07:00
|
|
|
rows: 5
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2020-04-06 11:04:59 -07:00
|
|
|
operation: ['find']
|
|
|
|
}
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
2020-04-06 11:04:59 -07:00
|
|
|
default: '{}',
|
2020-04-05 18:06:00 -07:00
|
|
|
placeholder: `{ "birth": { "$gt": "1950-01-01" } }`,
|
|
|
|
required: true,
|
2020-04-06 11:04:59 -07:00
|
|
|
description: 'MongoDB Find query.'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// insert
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'Fields',
|
|
|
|
name: 'fields',
|
|
|
|
type: 'string',
|
2020-04-05 18:06:00 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2020-04-06 11:04:59 -07:00
|
|
|
operation: ['insert']
|
|
|
|
}
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
2020-04-06 11:04:59 -07:00
|
|
|
default: '',
|
|
|
|
placeholder: 'name,description',
|
2020-04-05 18:06:00 -07:00
|
|
|
description:
|
2020-04-06 11:04:59 -07:00
|
|
|
'Comma separated list of the fields to be included into the new document.'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// update
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'Update Key',
|
|
|
|
name: 'updateKey',
|
|
|
|
type: 'string',
|
2020-04-05 18:06:00 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2020-04-06 11:04:59 -07:00
|
|
|
operation: ['update']
|
|
|
|
}
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
2020-04-06 11:04:59 -07:00
|
|
|
default: 'id',
|
2020-04-05 18:06:00 -07:00
|
|
|
required: true,
|
|
|
|
description:
|
2020-04-06 11:04:59 -07:00
|
|
|
'Name of the property which decides which rows in the database should be updated. Normally that would be "id".'
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-06 11:04:59 -07:00
|
|
|
displayName: 'Fields',
|
|
|
|
name: 'fields',
|
|
|
|
type: 'string',
|
2020-04-05 18:06:00 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2020-04-06 11:04:59 -07:00
|
|
|
operation: ['update']
|
|
|
|
}
|
2020-04-05 18:06:00 -07:00
|
|
|
},
|
2020-04-06 11:04:59 -07:00
|
|
|
default: '',
|
|
|
|
placeholder: 'name,description',
|
2020-04-05 18:06:00 -07:00
|
|
|
description:
|
2020-04-06 11:04:59 -07:00
|
|
|
'Comma separated list of the fields to be included into the new document.'
|
|
|
|
}
|
|
|
|
]
|
2020-04-05 18:06:00 -07:00
|
|
|
};
|