{{#ifIncludes LINK.path  "/by-slug" }}
const q = this.{{SUB_MODULE_ENTITY_CAMELCASED_SINGULAR}}Model.findOne({ slug });
{{else}}
{{#ifIncludes LINK.path  "/by-name" }}
const q = this.{{SUB_MODULE_ENTITY_CAMELCASED_SINGULAR}}Model.findOne({ name });
{{else}}
{{#ifIncludes LINK.path  "/by-tracking" }}
const q = this.{{SUB_MODULE_ENTITY_CAMELCASED_SINGULAR}}Model.findOne({ tracking_id });
{{else}}
{{#ifIncludes LINK.path  "/by-token" }}
const q = this.{{SUB_MODULE_ENTITY_CAMELCASED_SINGULAR}}Model.findOne({ token });
{{else}}
const q = this.{{SUB_MODULE_ENTITY_CAMELCASED_SINGULAR}}Model.findById(id);
{{/ifIncludes}}
{{/ifIncludes}}
{{/ifIncludes}}
{{/ifIncludes}}

/**
  * @description Lean the query else if needed to not do so
  */
if (!opt.dontLean) q.lean();


const doc = await q.exec();


if (!doc) {
  if(opt.ignoreNotFoundException) return {data: undefined};
  throw new exceptions.ItemNotFoundException('{{capitalize ENTITY_NAMING.entityWords}} not found');
}

/**
  * Check if the document is deleted and the user does not want to load deleted documents
  */
if (doc.is_deleted && !opt.loadDeleted) throw new exceptions.ItemNotFoundException('{{capitalize ENTITY_NAMING.entityWords}} deleted');

/**
* Check if the user can view the {{ENTITY_NAMING.entityWords}}
*/
const userGranted = await userCan.viewObject(this.ENTITY, doc, authData);
if (!opt.bypassAuthorization && !userGranted) throw new exceptions.UnauthorizedException('You are not allowed to view this {{ENTITY_NAMING.entityWords}}');

result = {
  data: mapDocumentToExposed(doc)
};