2020-04-04 07:04:25 -07:00
import { INodeProperties } from 'n8n-workflow' ;
2021-12-03 00:44:16 -08:00
export const collectionOperations : INodeProperties [ ] = [
2020-04-04 07:04:25 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-04-04 07:04:25 -07:00
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ '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' ,
2022-07-10 13:50:51 -07:00
action : 'Create a collection entry' ,
2020-04-04 07:04:25 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-option-name-wrong-for-get-many
name : 'Get Many Entries' ,
2020-04-05 06:49:47 -07:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many collection entries' ,
2022-09-08 08:10:13 -07:00
action : 'Get many collection entries' ,
2020-04-04 07:04:25 -07:00
} ,
{
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' ,
2022-07-10 13:50:51 -07:00
action : 'Update a collection entry' ,
2020-04-04 07:04:25 -07:00
} ,
] ,
2020-04-05 06:49:47 -07:00
default : 'getAll' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2020-04-04 07:04:25 -07:00
2021-12-03 00:44:16 -08:00
export const collectionFields : INodeProperties [ ] = [
2020-04-05 06:49:47 -07:00
{
2022-06-03 10:23:49 -07:00
displayName : 'Collection Name or ID' ,
2020-04-05 06:49:47 -07:00
name : 'collection' ,
type : 'options' ,
default : '' ,
typeOptions : {
loadOptionsMethod : 'getCollections' ,
} ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'collection' ] ,
2020-04-05 06:49:47 -07:00
} ,
} ,
required : true ,
2022-08-01 13:47:55 -07:00
description :
'Name of the collection to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
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 : {
2022-08-01 13:47:55 -07:00
operation : [ 'getAll' ] ,
resource : [ 'collection' ] ,
2020-04-06 01:03:49 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-04-06 01:03:49 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
operation : [ 'getAll' ] ,
resource : [ 'collection' ] ,
returnAll : [ false ] ,
2020-04-06 01:03:49 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 500 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-04-06 01:03:49 -07:00
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'collection' ] ,
operation : [ 'getAll' ] ,
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 : '' ,
2020-04-12 03:28:36 -07:00
placeholder : '_id,name' ,
2022-05-06 14:01:25 -07:00
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"}' ,
2022-08-01 13:47:55 -07:00
description :
'Filter query in <a href="https://jeroen.github.io/mongolite/query-data.html">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 : '' ,
2022-05-06 14:01:25 -07:00
description : 'Return normalized language fields' ,
2020-04-04 07:04:25 -07:00
} ,
{
displayName : 'Populate' ,
name : 'populate' ,
type : 'boolean' ,
default : true ,
2022-06-20 07:54:01 -07:00
description : 'Whether to resolve linked collection items' ,
2020-04-04 07:04:25 -07:00
} ,
2020-04-05 06:49:47 -07:00
{
displayName : 'RAW Data' ,
name : 'rawData' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to return the data exactly in the way it got received from the API' ,
2020-04-05 06:49:47 -07:00
} ,
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 : '' ,
2022-05-06 14:01:25 -07:00
description : 'Skip number of entries' ,
2020-04-05 06:49:47 -07:00
} ,
{
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}' ,
2022-08-01 13:47:55 -07:00
description :
'Sort query in <a href="https://jeroen.github.io/mongolite/query-data.html">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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'collection' ] ,
operation : [ 'update' ] ,
2020-04-04 07:04:25 -07:00
} ,
} ,
} ,
2020-04-11 11:24:51 -07:00
// Collection:entry:create
// Collection:entry:update
{
2022-06-03 10:23:49 -07:00
displayName : 'JSON Data Fields' ,
2020-04-11 11:24:51 -07:00
name : 'jsonDataFields' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'collection' ] ,
operation : [ 'create' , 'update' ] ,
2020-04-11 11:24:51 -07:00
} ,
} ,
2022-06-20 07:54:01 -07:00
description : 'Whether new entry fields should be set via the value-key pair UI or JSON' ,
2020-04-11 11:24:51 -07:00
} ,
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 : {
2022-08-01 13:47:55 -07:00
jsonDataFields : [ true ] ,
resource : [ 'collection' ] ,
operation : [ 'create' , 'update' ] ,
2020-04-11 11:24:51 -07:00
} ,
} ,
2022-05-06 14:01:25 -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 : {
2022-08-01 13:47:55 -07:00
jsonDataFields : [ false ] ,
resource : [ 'collection' ] ,
operation : [ 'create' , 'update' ] ,
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 : '' ,
2022-05-06 14:01:25 -07:00
description : 'Name of the field' ,
2020-04-11 11:24:51 -07:00
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value of the field' ,
2020-04-11 11:24:51 -07:00
} ,
] ,
} ,
] ,
2022-05-06 14:01:25 -07:00
description : 'Entry data to send' ,
2020-04-04 07:04:25 -07:00
} ,
2021-12-03 00:44:16 -08:00
] ;