Skip to main content

createManyAndReturn()

Used to add multiple rows to the target sheet simultaneously and retrieve all created records as an array.

Performs the same write operation as createMany, but differs in the return value.

Available Keys

KeyDescriptionOptionalNotes
dataSpecifies the data to registerRequired
selectDisplay settings for return value columnsOptionalCannot be used with omit / include
omitExclusion settings for return value columnsOptionalCannot be used with select
includeRetrieve related recordsOptionalDetails here

Example Sheet

Example Sheet

Description

Suppose you want to add the following rows to the above example:

  • Row 1

    • name => Shibata
    • age => 23
    • pref => Shimane
    • postNumber => 690-8540
  • Row 2

    • name => Suzuhara
    • age => 25
    • pref => Tottori
    • postNumber => 680-8571

The code would be:

const gassma = new Gassma.GassmaClient();

// gassma.{{TARGET_SHEET_NAME}}.createManyAndReturn
const result = gassma.sheet1.createManyAndReturn({
data: [
{
name: "Shibata",
age: 23,
pref: "Shimane",
postNumber: "690-8540",
},
{
name: "Suzuhara",
age: 25,
pref: "Tottori",
postNumber: "680-8571",
},
],
});

The return value has the following format:

[
{ name: "Shibata", age: 23, pref: "Shimane", postNumber: "690-8540" },
{ name: "Suzuhara", age: 25, pref: "Tottori", postNumber: "680-8571" },
];

All created records are returned as an array.

Differences from createMany

MethodReturn Value
createMany{ count: number }
createManyAndReturnArray of created records

The behavior also differs when passing an empty array:

// createMany
gassma.sheet1.createMany({ data: [] });
// => undefined

// createManyAndReturn
gassma.sheet1.createManyAndReturn({ data: [] });
// => []

Fields not specified in data are returned as null:

const result = gassma.sheet1.createManyAndReturn({
data: [{ name: "Shibata" }],
});
// => [{ name: "Shibata", age: null, pref: null, postNumber: null }]
note

createManyAndReturn does not support Nested Write. Use create if you need to operate on related records simultaneously.