getDocumentByCriteria 🆕
Returns Case Insensitive SQL `LIKE` statement for DB query
Throws `errorNoCriteriaProvided` if props are empty.
Throws `errorDocumentNotFound` if document with specified id does not exist.
Signature
getDocumentByCriteria(session: MySQLSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND'): Promise<IDocument<S>>;
getDocumentByCriteria(session: MySQLXSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND'): Promise<IDocument<S>>;
Example
// employeeRouter.{ts|js}
import { employeeController } from './employeeController';
import { EmployeeProps } from './schemas/employee';
const officeId = '<_id>';
await db.usingSession(async (session) => {
const data = await employeeController.getDocumentByCriteria(session, { [EmployeeProps.officeId]: officeId });
return data;
}, transacted);
// employeeRouter.{ts|js}
import { employeeController } from './employeeController';
import { EmployeeProps } from './schemas/employee';
const officeId = '<_id>';
await db.usingSession(async (session) => {
const data = await employeeController.getDocumentByCriteria(session, { [EmployeeProps.officeId]: officeId });
return data;
}, transacted);
Last updated