searchDocuments 🆕
Search documents by prop and pattern. Case Insensitive. Makes text search by document. Uses default collation of the database.
Signature
searchDocuments(session: MySQLSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND', pagination?: IOffsetPagination, sort?: Sort): Promise<IPaginatedSet<IDocument<S>>>;
searchDocuments(session: MySQLXSession, props: Partial<IDocument<S>>, join?: 'OR' | 'AND', pagination?: IOffsetPagination): 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);
// 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);