Skip to main content

omit

$omit

Returns a new object or dense array with the specified keys/indices removed. Keys not present in the input are silently ignored. For arrays, numeric indices are excluded and the result is a dense (packed) array.

Parameters

  • Array of key names or indices (string[]|number[], required): The keys/indices to exclude.

Example

// Remove internal fields before returning a user object
new Schema('object').transformer({$omit: ['password', 'salt', '_internalId']})
// {id: 1, name: 'Alice', password: '...', _internalId: 42} → {id: 1, name: 'Alice'}

// Remove the first element from an array
new Schema('array').transformer({$omit: [0]})
// ['header', 'row1', 'row2'] → ['row1', 'row2']