mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Add clear functionality to Google Sheet-Node
This commit is contained in:
@@ -45,6 +45,27 @@ export class GoogleSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears values from a sheet
|
||||||
|
*
|
||||||
|
* @param {string} range
|
||||||
|
* @returns {Promise<object>}
|
||||||
|
* @memberof GoogleSheet
|
||||||
|
*/
|
||||||
|
async clearData(range: string): Promise<object> {
|
||||||
|
const client = await this.getAuthenticationClient();
|
||||||
|
|
||||||
|
const response = await Sheets.spreadsheets.values.clear(
|
||||||
|
{
|
||||||
|
auth: client,
|
||||||
|
spreadsheetId: this.id,
|
||||||
|
range,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cell values
|
* Returns the cell values
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ export class GoogleSheets implements INodeType {
|
|||||||
value: 'append',
|
value: 'append',
|
||||||
description: 'Appends the data to a Sheet',
|
description: 'Appends the data to a Sheet',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Clear',
|
||||||
|
value: 'clear',
|
||||||
|
description: 'Clears data from a Sheet',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Lookup',
|
name: 'Lookup',
|
||||||
value: 'lookup',
|
value: 'lookup',
|
||||||
@@ -172,6 +177,7 @@ export class GoogleSheets implements INodeType {
|
|||||||
hide: {
|
hide: {
|
||||||
operation: [
|
operation: [
|
||||||
'append',
|
'append',
|
||||||
|
'clear',
|
||||||
],
|
],
|
||||||
rawData: [
|
rawData: [
|
||||||
true
|
true
|
||||||
@@ -193,6 +199,9 @@ export class GoogleSheets implements INodeType {
|
|||||||
},
|
},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
hide: {
|
hide: {
|
||||||
|
operation: [
|
||||||
|
'clear',
|
||||||
|
],
|
||||||
rawData: [
|
rawData: [
|
||||||
true
|
true
|
||||||
],
|
],
|
||||||
@@ -266,6 +275,16 @@ export class GoogleSheets implements INodeType {
|
|||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Option',
|
||||||
default: {},
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'append',
|
||||||
|
'lookup',
|
||||||
|
'read',
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Return All Matches',
|
displayName: 'Return All Matches',
|
||||||
@@ -425,6 +444,15 @@ export class GoogleSheets implements INodeType {
|
|||||||
// TODO: Should add this data somewhere
|
// TODO: Should add this data somewhere
|
||||||
// TODO: Should have something like add metadata which does not get passed through
|
// TODO: Should have something like add metadata which does not get passed through
|
||||||
|
|
||||||
|
return this.prepareOutputData(items);
|
||||||
|
} else if (operation === 'clear') {
|
||||||
|
// ----------------------------------
|
||||||
|
// clear
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
await sheet.clearData(range);
|
||||||
|
|
||||||
|
const items = this.getInputData();
|
||||||
return this.prepareOutputData(items);
|
return this.prepareOutputData(items);
|
||||||
} else if (operation === 'lookup') {
|
} else if (operation === 'lookup') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user