Core
Framework v2.x
2

getId #

Available since 2.11.0

Returns the _id specified in the request.

Arguments #

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

Options:

NameTypeDescription
ifMissing
'error'
'generate'
generator
() => string
Function used to generate an ID

Example #

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" });