-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate.js
36 lines (32 loc) · 841 Bytes
/
create.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
let datafire = require('datafire');
var google_sheets = require('@datafire/google_sheets').actions;
module.exports = new datafire.Action({
description: "Creates a new item in the spreadsheet",
inputs: [{
title: "name",
type: "string",
maxLength: 100,
minLength: 1
}, {
title: "age",
type: "integer",
minimum: 0,
maximum: 200
}],
handler: (input, context) => {
return datafire.flow(context)
.then(_ => google_sheets.spreadsheets.values.append({
spreadsheetId: context.variables.spreadsheet_id,
range: "A1:A" + INPUTS.length,
body: {
values: [
INPUTS.map(i => input[i.title])
],
},
valueInputOption: "RAW",
}, context))
.then(_ => "Success")
},
});
const INPUTS = module.exports.inputs;