mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
✨ Add clear functionality to Google Sheet-Node
This commit is contained in:
parent
d6134ec405
commit
ac88d25e1b
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -47,6 +47,11 @@ export class GoogleSheets implements INodeType {
|
|||
value: 'append',
|
||||
description: 'Appends the data to a Sheet',
|
||||
},
|
||||
{
|
||||
name: 'Clear',
|
||||
value: 'clear',
|
||||
description: 'Clears data from a Sheet',
|
||||
},
|
||||
{
|
||||
name: 'Lookup',
|
||||
value: 'lookup',
|
||||
|
@ -172,6 +177,7 @@ export class GoogleSheets implements INodeType {
|
|||
hide: {
|
||||
operation: [
|
||||
'append',
|
||||
'clear',
|
||||
],
|
||||
rawData: [
|
||||
true
|
||||
|
@ -193,6 +199,9 @@ export class GoogleSheets implements INodeType {
|
|||
},
|
||||
displayOptions: {
|
||||
hide: {
|
||||
operation: [
|
||||
'clear',
|
||||
],
|
||||
rawData: [
|
||||
true
|
||||
],
|
||||
|
@ -266,6 +275,16 @@ export class GoogleSheets implements INodeType {
|
|||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'append',
|
||||
'lookup',
|
||||
'read',
|
||||
'update',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Return All Matches',
|
||||
|
@ -425,6 +444,15 @@ export class GoogleSheets implements INodeType {
|
|||
// TODO: Should add this data somewhere
|
||||
// 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);
|
||||
} else if (operation === 'lookup') {
|
||||
// ----------------------------------
|
||||
|
|
Loading…
Reference in a new issue