crud-node
  • ⚡Overview
  • ✨Installation
  • 🧰Schema (soon)
  • ☄️Quick Start
  • Guides
    • 🪄Guides (soon)
  • Adapters
    • 💫Adapters
      • Availability 🆕
      • MySQL
      • MySQLX
      • Mongo (soon)
      • Postgres (soon)
      • Cassandra (soon)
      • Oracle (soon)
      • SqlLite (soon)
      • Couchdb (soon)
  • Reference
    • ⭐API Reference
      • Availability 🆕
      • init
      • toString
      • createDocument
      • createDocumentIfNotExists 🆕
      • deleteDocument
      • deleteAll 🆕
      • updateDocument
      • getDocument
      • getDocuments
      • getDocumentByCriteria 🆕
      • searchDocumentsByCriteria 🆕
      • searchDocuments 🆕
      • groupByDocuments 🆕
      • filterDocumentsByCriteria 🆕
      • filterDocuments 🆕
      • filterDocumentsByIds 🆕
      • fetchAll 🆕
      • findDocument 🆕
      • existsDocument
      • getCount
      • getTotal
      • callStoredProcedure 🆕
  • 📃Changelog
  • 📋Roadmap
Powered by GitBook
On this page
  1. Reference
  2. API Reference

filterDocuments 🆕

Filter documents by props. Case Sensitive.

Throws `errorNoCriteriaProvided` if props are empty.

Signature

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

Example

// employeeRouter.{ts|js}
import { OffsetPagination } from 'crud-node';
import { employeeController } from './employeeController';

const transacted = true;

await db.usingSession(async (session) => {
  const pagination = OffsetPagination(1, 10);
  const data = await employeeController.filterDocuments(session, { fired: true }, 'AND', pagination);
  return data;
}, transacted);
// employeeRouter.{ts|js}
import { OffsetPagination } from 'crud-node';
import { employeeController } from './employeeController';

const transacted = true;

await db.usingSession(async (session) => {
  const pagination = OffsetPagination(1, 10);
  const data = await employeeController.filterDocuments(session, { fired: true }, 'AND', pagination);
  return data;
}, transacted);
PreviousfilterDocumentsByCriteria 🆕NextfilterDocumentsByIds 🆕

Last updated 2 years ago

⭐