findDocument 🆕

Find documents by props. Case Insensitive. Returns undefined, if document was not found.

Throws `errorNoCriteriaProvided` if props are empty.

Signature

findDocument(session: MySQLSession, props: Partial<IDocument<S>>): Promise<IDocument<S> | undefined>;

Example

// employeeRouter.{ts|js}
import { employeeController } from './employeeController';

const transacted = true;

await db.usingSession(async (session) => {
  const employeeId = '<id>';
  const data = await employeeController.findDocument(session, { employeeId });
  return data;
}, transacted);

Last updated