@sensenet/query
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@sensenet/query

NPM version NPM downloads License: GPL v2

Install

# Yarn
yarn add @sensenet/query

# NPM
npm install @sensenet/query

Usage

The package allows you to create strongly typed content queries that will be evaluated into sensenet queries

Usage example:

const query = new Query(
  (q) =>
    q
      .typeIs<Task>('Task') // adds '+TypeIs:Task' and Typescript type cast
      .and.equals('DisplayName', 'Unicorn') // adds +Title:Unicorn
      .and.between('ModificationDate', '2017-01-01T00:00:00', '2017-02-01T00:00:00')
      .or.query(
        (sub) =>
          sub // Grouping
            .notEquals('Approvable', true)
            .and.notEquals('Description', '*alma*'), // Contains with wildcards
      )
      .sort('DisplayName')
      .top(5) // adds .TOP:5
      .skip(10), // adds .SKIP:10
)

console.log(query.toString())
// "TypeIs:Task AND DisplayName:'Unicorn' AND ModificationDate:{'2017-01-01T00\\:00\\:00' TO '2017-02-01T00\\:00\\:00'} OR (NOT(Approvable:'true') AND NOT(Description:'*alma*')) .SORT:DisplayName .TOP:5 .SKIP:10"

Dependents (5)

Package Sidebar

Install

npm i @sensenet/query

Homepage

sensenet.com

Weekly Downloads

9

Version

3.0.0

License

GPL-2.0

Unpacked Size

230 kB

Total Files

43

Last publish

Collaborators

  • hassanad
  • kubehu
  • herflis
  • tusmester
  • kavics
  • vargajoe