searchDocuments 🆕

Search documents by prop and pattern. Case Insensitive. Makes text search by document. Uses default collation of the database.

Throws `errorNoCriteriaProvided` if props are empty.

Signature

searchDocuments(session: MySQLSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND', pagination?: IOffsetPagination, sort?: Sort): Promise<IPaginatedSet<IDocument<S>>>;

Example

// officeRouter.{ts|js}
import { officeController } from './officeController';
import { OfficeProps } from './schemas/office';

const transacted = true;

await db.usingSession(async (session) => {
  const data = await officeController.searchDocuments(
    session,
    {
      name: '%coworking%',
      officeCode: '%coworking%',
    },
    'OR',
  );
  return data;
}, transacted);

Last updated