2020-04-04 07:04:25 -07:00
|
|
|
import { INodeProperties } from 'n8n-workflow';
|
|
|
|
|
|
|
|
export const collectionOperations = [
|
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
2020-04-06 01:03:49 -07:00
|
|
|
'collection',
|
2020-04-04 07:04:25 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
name: 'Create an Entry',
|
2020-04-05 06:49:47 -07:00
|
|
|
value: 'create',
|
2020-04-04 07:04:25 -07:00
|
|
|
description: 'Create a collection entry',
|
|
|
|
},
|
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
name: 'Get all Entries',
|
2020-04-05 06:49:47 -07:00
|
|
|
value: 'getAll',
|
2020-04-04 07:04:25 -07:00
|
|
|
description: 'Get all collection entries',
|
|
|
|
},
|
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
name: 'Update an Entry',
|
2020-04-04 07:04:25 -07:00
|
|
|
value: 'update',
|
2020-07-24 03:56:41 -07:00
|
|
|
description: 'Update a collection entry',
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
],
|
2020-04-05 06:49:47 -07:00
|
|
|
default: 'getAll',
|
2020-04-04 07:04:25 -07:00
|
|
|
description: 'The operation to perform.',
|
2020-04-05 06:49:47 -07:00
|
|
|
},
|
2020-04-04 07:04:25 -07:00
|
|
|
] as INodeProperties[];
|
|
|
|
|
|
|
|
export const collectionFields = [
|
2020-04-05 06:49:47 -07:00
|
|
|
{
|
|
|
|
displayName: 'Collection',
|
|
|
|
name: 'collection',
|
|
|
|
type: 'options',
|
|
|
|
default: '',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getCollections',
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
2020-04-06 01:03:49 -07:00
|
|
|
'collection',
|
2020-04-05 06:49:47 -07:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
2020-10-22 06:46:03 -07:00
|
|
|
description: 'Name of the collection to operate on.',
|
2020-04-05 06:49:47 -07:00
|
|
|
},
|
|
|
|
|
2020-04-06 01:03:49 -07:00
|
|
|
// Collection:entry:getAll
|
|
|
|
{
|
|
|
|
displayName: 'Return All',
|
|
|
|
name: 'returnAll',
|
|
|
|
type: 'boolean',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'collection',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: false,
|
|
|
|
description: 'If all results should be returned or only up to a given limit.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Limit',
|
|
|
|
name: 'limit',
|
|
|
|
type: 'number',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'collection',
|
|
|
|
],
|
|
|
|
returnAll: [
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
typeOptions: {
|
|
|
|
minValue: 1,
|
|
|
|
maxValue: 500,
|
|
|
|
},
|
|
|
|
default: 100,
|
|
|
|
description: 'How many results to return.',
|
|
|
|
},
|
2020-04-04 07:04:25 -07:00
|
|
|
{
|
2020-04-05 06:49:47 -07:00
|
|
|
displayName: 'Options',
|
|
|
|
name: 'options',
|
2020-04-04 07:04:25 -07:00
|
|
|
type: 'collection',
|
2020-04-05 06:49:47 -07:00
|
|
|
placeholder: 'Add Option',
|
2020-04-04 07:04:25 -07:00
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
2020-04-06 01:03:49 -07:00
|
|
|
'collection',
|
2020-04-04 07:04:25 -07:00
|
|
|
],
|
|
|
|
operation: [
|
2020-04-05 06:49:47 -07:00
|
|
|
'getAll',
|
2020-10-22 06:46:03 -07:00
|
|
|
],
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Fields',
|
|
|
|
name: 'fields',
|
2020-04-12 03:28:36 -07:00
|
|
|
type: 'string',
|
2020-04-04 07:04:25 -07:00
|
|
|
default: '',
|
|
|
|
typeOptions: {
|
|
|
|
alwaysOpenEditWindow: true,
|
|
|
|
},
|
2020-04-12 03:28:36 -07:00
|
|
|
placeholder: '_id,name',
|
|
|
|
description: 'Comma separated list of fields to get.',
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
displayName: 'Filter Query',
|
2020-04-04 07:04:25 -07:00
|
|
|
name: 'filter',
|
|
|
|
type: 'json',
|
|
|
|
default: '',
|
|
|
|
typeOptions: {
|
|
|
|
alwaysOpenEditWindow: true,
|
|
|
|
},
|
2020-04-12 03:28:36 -07:00
|
|
|
placeholder: '{"name": "Jim"}',
|
|
|
|
description: 'Filter query in <a href="https://jeroen.github.io/mongolite/query-data.html" target="_blank">Mongolite format</a>.',
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-05 06:49:47 -07:00
|
|
|
displayName: 'Language',
|
|
|
|
name: 'language',
|
|
|
|
type: 'string',
|
2020-04-04 07:04:25 -07:00
|
|
|
default: '',
|
2020-04-05 06:49:47 -07:00
|
|
|
description: 'Return normalized language fields.',
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Populate',
|
|
|
|
name: 'populate',
|
|
|
|
type: 'boolean',
|
|
|
|
required: true,
|
|
|
|
default: true,
|
|
|
|
description: 'Resolve linked collection items.',
|
|
|
|
},
|
2020-04-05 06:49:47 -07:00
|
|
|
{
|
|
|
|
displayName: 'RAW Data',
|
|
|
|
name: 'rawData',
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
description: `Returns the data exactly in the way it got received from the API.`,
|
|
|
|
},
|
2020-04-04 07:04:25 -07:00
|
|
|
{
|
2020-04-05 06:49:47 -07:00
|
|
|
displayName: 'Skip',
|
|
|
|
name: 'skip',
|
|
|
|
type: 'number',
|
2020-04-04 07:04:25 -07:00
|
|
|
default: '',
|
2020-04-05 06:49:47 -07:00
|
|
|
description: 'Skip number of entries.',
|
|
|
|
},
|
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
displayName: 'Sort Query',
|
2020-04-05 06:49:47 -07:00
|
|
|
name: 'sort',
|
|
|
|
type: 'json',
|
|
|
|
default: '',
|
2020-04-12 03:28:36 -07:00
|
|
|
placeholder: '{"price": -1}',
|
|
|
|
description: 'Sort query in <a href="https://jeroen.github.io/mongolite/query-data.html" target="_blank">Mongolite format</a>.',
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2020-04-06 01:03:49 -07:00
|
|
|
// Collection:entry:update
|
2020-04-04 07:04:25 -07:00
|
|
|
{
|
|
|
|
displayName: 'Entry ID',
|
|
|
|
name: 'id',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
2020-04-06 01:03:49 -07:00
|
|
|
'collection',
|
2020-04-04 07:04:25 -07:00
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'update',
|
2020-10-22 06:46:03 -07:00
|
|
|
],
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'The entry ID.',
|
|
|
|
},
|
2020-04-11 11:24:51 -07:00
|
|
|
|
|
|
|
// Collection:entry:create
|
|
|
|
// Collection:entry:update
|
|
|
|
{
|
|
|
|
displayName: 'JSON Data fields',
|
|
|
|
name: 'jsonDataFields',
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'collection',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
'update',
|
2020-10-22 06:46:03 -07:00
|
|
|
],
|
2020-04-11 11:24:51 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
description: 'If new entry fields should be set via the value-key pair UI or JSON.',
|
|
|
|
},
|
2020-04-04 07:04:25 -07:00
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
displayName: 'Entry Data',
|
2020-04-11 11:24:51 -07:00
|
|
|
name: 'dataFieldsJson',
|
2020-04-04 07:04:25 -07:00
|
|
|
type: 'json',
|
|
|
|
default: '',
|
|
|
|
typeOptions: {
|
|
|
|
alwaysOpenEditWindow: true,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
2020-04-11 11:24:51 -07:00
|
|
|
jsonDataFields: [
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
resource: [
|
|
|
|
'collection',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
'update',
|
2020-10-22 06:46:03 -07:00
|
|
|
],
|
2020-04-11 11:24:51 -07:00
|
|
|
},
|
|
|
|
},
|
2020-04-12 03:28:36 -07:00
|
|
|
description: 'Entry data to send as JSON.',
|
2020-04-11 11:24:51 -07:00
|
|
|
},
|
|
|
|
{
|
2020-04-12 03:28:36 -07:00
|
|
|
displayName: 'Entry Data',
|
2020-04-11 11:24:51 -07:00
|
|
|
name: 'dataFieldsUi',
|
|
|
|
type: 'fixedCollection',
|
|
|
|
typeOptions: {
|
|
|
|
multipleValues: true,
|
|
|
|
},
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
jsonDataFields: [
|
|
|
|
false,
|
|
|
|
],
|
2020-04-04 07:04:25 -07:00
|
|
|
resource: [
|
2020-04-06 01:03:49 -07:00
|
|
|
'collection',
|
2020-04-04 07:04:25 -07:00
|
|
|
],
|
|
|
|
operation: [
|
2020-04-11 11:24:51 -07:00
|
|
|
'create',
|
2020-04-04 07:04:25 -07:00
|
|
|
'update',
|
2020-10-22 06:46:03 -07:00
|
|
|
],
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
},
|
2020-04-11 11:24:51 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Field',
|
|
|
|
name: 'field',
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
displayName: 'Name',
|
|
|
|
name: 'name',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Name of the field.',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Value',
|
|
|
|
name: 'value',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
description: 'Value of the field.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-04-12 03:28:36 -07:00
|
|
|
description: 'Entry data to send.',
|
2020-04-04 07:04:25 -07:00
|
|
|
},
|
|
|
|
] as INodeProperties[];
|