getCollection #

Available since 2.11.0

Returns the collection specified in the request.

Arguments #

getCollection (options: { required?: boolean } = {}): string

Options:

NameTypeDescriptionDefault
required
boolean
If true, throws an api.assert.missing_argument error when the collection is missing. If false, returns null insteadtrue

Example #

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

// returns null if no collection is provided
const collection = request.getCollection({ required: false });