Core
Framework v2.x
2

getId #

Available since 2.11.0

Returns the _id specified in the request.

Arguments #

Copied to clipboard!
getId (
    options: {
      ifMissing?: 'error' | 'generate' | 'ignore',
      generator?: () => string,
    } = { generator: uuid.v4, ifMissing: 'error' }
  ): string

Options:

Name Type Description
ifMissing
'error'
'generate'
generator
() => string
Function used to generate an ID

Example #

Copied to clipboard!
const id = request.getId();
// equivalent
const id = request.input.args._id;
//+ checks to make sure that "_id" is of the right type
// and throw standard API error when it's not the case

// generate a default ID if it's missing
const id = request.getId({ ifMissing: "generate" });