Skip to main content

Basic

Creating an Instance

If you have created a GAS on a specific spreadsheet and want to work with that spreadsheet, you can create an instance as follows:

const gassma = new Gassma.GassmaClient();

Alternatively, if you have created a GAS in a location other than a spreadsheet, or if you want to work with a spreadsheet located elsewhere, you can create an instance by passing the target spreadsheet's ID as an argument:

const gassma = new Gassma.GassmaClient("XXXXXXXXXXXXXXXXXXX");

Initialization with an Options Object

When you need advanced configuration such as relation definitions or global omit, pass an options object:

const gassma = new Gassma.GassmaClient({
id: "XXXXXXXXXXXXXXXXXXX", // Optional
relations: {
// Relation definitions (see the relation definition reference for details)
},
omit: {
// Global omit settings (see the global omit reference for details)
Users: { password: true },
},
});
OptionDescriptionReference
idSpreadsheet ID (uses the active spreadsheet when omitted)-
relationsRelation definitionsRelation Definition
omitGlobal omit settingsGlobal omit
defaultsDefault values for fieldsdefaults
updatedAtAuto-update timestampsupdatedAt
ignoreField-level exclusionignore
ignoreSheetsSheet-level exclusionignore
mapField name mappingmap
mapSheetsSheet name mappingmap
autoincrementAuto-incrementautoincrement
strictUndefinedChecksTurns explicit undefined in query inputs into runtime errorsstrictUndefinedChecks / Gassma.skip

Checking Date Values

GASsma runs as a GAS library in a script context separate from the calling script. As a result, checking a Date value returned by GASsma with instanceof Date evaluates to false. Use Object.prototype.toString instead:

const user = gassma.Users.findFirst({ where: { id: 1 } });

user.createdAt instanceof Date;
// => false (a Date crossing the library boundary cannot be checked with instanceof)

Object.prototype.toString.call(user.createdAt) === "[object Date]";
// => true
note

This limitation applies to instanceof on built-in types such as Date. GASsma's exported error classes (e.g., Gassma.GassmaMissingArgumentError) are referenced via the Gassma namespace (the library's global), so they can be checked with instanceof. For details, see the error list.