notion-query-builder

0.4.0

Getting Started

Notion-query-builder

Notion-query-builder is an opinionated filter query builder written in Typescript for use with the official Notion javascript client.

Note: This software is not affliated with Notion Labs, Inc. Issues and/or support should relating to this library be directed to the project's issue tracker.

Prerequisites

Compatibility Version Id
Notion API 2022-06-28
Notion JS SDK v2.2.3+
Javascript ES2019+

Installation

NodeJS

npm i notion-query-builder

// or alternatively, [yarn|pnpm] add notion-query-builder

Deno

import nob from 'https://deno.land/x/notion_query_builder/mod.ts'

// note: for a smaller package size, try the npm version as it's stripped of development artifacts
import nob from 'npm:notion-query-builder'

Usage

As your filter queries become more complex, so does the size of the JSON you'll write for them. Large unwieldy blocks of JSON are always a hassle to reason about and maintain - often, solutions to manage this data utimately leads to code bloat.

node-query-builder offers a simple and easy-to-use API to write filters and conditions programatically, reducing the effort and amount of code required by many factors.

To get started, here's a high level overview of the library:

  • filters and conditions are functions which combine to construct a query.
  • Usually, filters take conditions as arguments but special filters may take other filters as arguments
  • To use with the client, the constructed query needs to return its JSON output. This is usually done by calling the toJSON() method.
import { Client } from '@notionhq/client';
import nob from 'notion-query-builder';

const notion = new Client({ auth: process.env.NOTION_API_KEY });

const myFilter = nob.filterQuery([
  nob.checkboxFilter('Published', nob.equal(true)),
  nob.multiSelectFilter('Tags', nob.contains(['A', 'B']))
]);

const response = await notion.databases.query({
  database_id: databaseId,
  filter: myFilter.toJson()
});
{
  "and": [
    {
      "property": "Published",
      "checkbox": {
        "equals": true
      }
    },
    {
      "property": "Tags",
      "multi_select": {
        "contains": "A"
      }
    },
    {
      "property": "Tags",
      "multi_select": {
        "contains": "B"
      }
    }
  ]
}

Credits

notion-query-builder is inspired by elastic-builder and the countless hours it has saved writing ElasticSearch queries.

Licence

MIT

Donate

A random charity appears!

Young Women's Trust

Young Women’s Trust offers support to young women aged 18 to 30, who are living on low or no pay and want to build a better future, through Work It Out. Work It Out is a free service that offers coaching and personalised feedback on CV and job applications.

Org: Young Women's Trust, reg. charity no. 217868

Donate: https://www.youngwomenstrust.org/donate/

Queries and Special Filters

Queries and special filters take other filters as arguments

A filter is a single condition used to specify and limit the entries returned from a database query. Database queries can be filtered by page property values. The API supports filtering by the following property types: rich_text, phone_number, number, checkbox, select, multi-select, date, people, files, relation, status, and formula. You may also filter a database by created_time or last_edited_time, even if these aren't present as properties on the database.

Official Reference

new FilterQuery(childFilters: (FilterQueryFilter | Array<FilterQueryFilter>))
Parameters
Example
const query = nob.filterQuery(nob.textQuery('name', nob.equal('Jim')))

// when given array, filterQuery() autowraps child filters in a new CompoundFilter with an "and" list
const query = nob.filterQuery([
 nob.textQuery('name', nob.equal('Jack')),
 nob.textQuery('name', nob.equal('Jill'))
])

const query = nob.filterQuery(
 nob.compoundFilter()
 .or(nob.textQuery('name', nob.equal('Jack')))
 .or(nob.textQuery('name', nob.equal('Jill')))
)
Instance Members

A compound filter object combines several filter objects together using a logical operator and or or. A compound filter can even be combined within a compound filter, but only up to two nesting levels deep.

Official Reference

new CompoundFilter()

Extends Filter

Example
const filter = nob.compoundFilter()
 .and(nob.checkboxFilter('Write todo list', nob.equal(true))
 .or(nob.textFilter('name', nob.contain('Bridge')))
Instance Members
and(childFilter)
or(childFilter)

A rollup filter condition can be applied to database properties of type "rollup". Rollups which evaluate to arrays accept a filter with an any, every, or none condition; rollups which evaluate to numbers accept a filter with a number condition; and rollups which evaluate to dates accept a filter with a date condition.

Official Reference

new RollUpFilter(aggregation: RollUpFilterAggregationType, childFilter: RollUpFilterFilter)

Extends TermFilter

Parameters
aggregation (RollUpFilterAggregationType) the aggregation type to use
childFilter (RollUpFilterFilter) the child filter for the rollup
Example
const filter = nob.rollUpFilter('any', nob.numberQuery('age', nob.greaterThan(12)))
Instance Members

A formula filter condition can be applied to database properties of type "formula".

Official Reference

new FormulaFilter(aggregation: FormulaFilterAggregationType, childFilter: FormulaFilterFilter)

Extends TermFilter

Parameters
aggregation (FormulaFilterAggregationType) the aggregation type to use
childFilter (FormulaFilterFilter) the child filter for the formula
Example
const filter = nob.formulaFilter('number', nob.numberQuery('age', nob.greaterThan(12)))
Instance Members

Term Level Filters

Term Level Filters take Conditions as arguments

A text filter condition can be applied to database properties of types "title", "rich_text", "url", "email", and "phone_number".

Official Reference

new TextFilter(property: string, conditions: (TextFilterCondition | Array<TextFilterCondition>), filterType: TextPropertyFilterType)

Extends TermFilter

Parameters
property (string) the database property
filterType (TextPropertyFilterType = rich_text)
Example
const filter = nob.textFilter('Name', nob.equal('Jim'))
const filter = nob.textFilter('Name', nob.equal('My blog title'), 'title')
const filter = nob.textFilter('Name', nob.equal('http://notion.com'), 'url')
const filter = nob.textFilter('Name', nob.equal('hello@example.com'), 'email')
const filter = nob.textFilter('Name', nob.equal('000000000000'), 'phone_number')
Instance Members

A number filter condition can be applied to database properties of type "number".

Official Reference

new NumberFilter(property: string, conditions: (NumberFilterCondition | Array<NumberFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.numberFilter('age', nob.equal(12))
const filter = nob.numberFilter('age', nob.greaterThan(12))
Instance Members

A checkbox filter condition can be applied to database properties of type "checkbox".

Official Reference

new CheckboxFilter(property: string, conditions: (CheckboxFilterCondition | Array<CheckboxFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.checkboxFilter('Write todo list', nob.equal(true))
Instance Members

A select filter condition can be applied to database properties of type "select".

Official Reference

new SelectFilter(property: string, conditions: (SelectFilterCondition | Array<SelectFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.selectFilter('assignee', nob.eq('Jim'))
Instance Members

MultiSelectFilter

src/filter/multiSelect.ts

A multi-select filter condition can be applied to database properties of type "multi_select".

Official Reference

new MultiSelectFilter(property: string, conditions: (MultiSelectFilterCondition | Array<MultiSelectFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.multiSelectFilter('fruits', nob.equal('apple'))
const filter = nob.multiSelectFilter('fruits', nob.equal(['apple', 'pear']))
Instance Members

MultiSelectFilter

src/filter/multiselect.ts

A multi-select filter condition can be applied to database properties of type "multi_select".

Official Reference

new MultiSelectFilter(property: string, conditions: (MultiSelectFilterCondition | Array<MultiSelectFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.multiSelectFilter('fruits', nob.equal('apple'))
const filter = nob.multiSelectFilter('fruits', nob.equal(['apple', 'pear']))
Instance Members

A status filter condition can be applied to database properties of type "status".

Official Reference

new StatusFilter(property: string, conditions: (StatusFilterCondition | Array<StatusFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.statusFilter('status', nob.eq('In Progress'))
Instance Members

A date filter condition can be applied to database properties of types "date", "created_time", and "last_edited_time".

Official Reference

new DateFilter(property: string, conditions: (DateFilterCondition | Array<DateFilterCondition>), filterType: DateTimestampFilterType)

Extends TermFilter

Parameters
property (string) the database property
filterType (DateTimestampFilterType = date)
Example
const filter = nob.dateFilter('published_date', nob.onOrAfter('2023-01-01'))
const filter = nob.dateFilter('blog', nob.after('2023-01-01'), 'created_time')
const filter = nob.dateFilter('blog', nob.after('2023-01-01'), 'last_edited_time')
Instance Members

A people filter condition can be applied to database properties of types "people", "created_by", and "last_edited_by".

Official Reference

new PeopleFilter(property: string, conditions: (PeopleFilterCondition | Array<PeopleFilterCondition>), filterType: PeoplePropertyFilterType)

Extends TermFilter

Parameters
property (string) the database property
filterType (PeoplePropertyFilterType = people)
Example
const filter = nob.peopleFilter('firstName', nob.equal('Jim'))
const filter = nob.peopleFilter('firstName', nob.equal('Jim'), 'created_by')
const filter = nob.peopleFilter('firstName', nob.equal('Jim'), 'last_edited_by')
Instance Members

A files filter condition can be applied to database properties of type "files".

Official Reference

new FilesFilter(property: string, conditions: (FilesFilterCondition | Array<FilesFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.filesFilter('fileType', nob.equal('pdf'))
Instance Members

A relation filter condition can be applied to database properties of type "relation".

Official Reference

new RelationFilter(property: string, conditions: (RelationFilterCondition | Array<RelationFilterCondition>))

Extends TermFilter

Parameters
property (string) the database property
Example
const filter = nob.relationFilter('user', nob.contains('6c574cee-ca68-41c8-86e0-1b9e992689fb'))
Instance Members

Conditions

Conditions take native data types as arguments

Only return pages where the page property value matches the provided value exactly.

new EqualCondition(params: (string | number | boolean | Array<(string | number | boolean)>))

Extends Condition

Parameters
params ((string | number | boolean | Array<(string | number | boolean)>)) the condition value
Example
const condition = nob.equal('Bridge')
const condition = nob.equal(['Bridge', 'Moat'])
const condition = nob.equal(12)
const condition = nob.equal(false)

// aliases
export condition = nob.equals('Bridge')
export condition = nob.eq('Bridge')
export condition = nob.is('Bridge')
export condition = nob.be('Bridge')

NotEqualCondition

src/condition/notEqual.ts

Only return pages where the page property value does not match the provided value exactly.

new NotEqualCondition(params: (string | number | boolean | Array<(string | number | boolean)>))

Extends Condition

Parameters
params ((string | number | boolean | Array<(string | number | boolean)>)) the condition value
Example
const condition = nob.notEqual('Bridge')
const condition = nob.notEqual(['Bridge', 'Moat'])
const condition = nob.notEqual(12)
const condition = nob.notEqual(false)

// aliases
const condition = nob.notEquals('Bridge')
const condition = nob.neq('Bridge')
const condition = nob.isnt('Bridge')
const condition = nob.isNot('Bridge')

Only return pages where the page property value is empty.

new EmptyCondition()

Extends Condition

Example
const condition = nob.empty()

// aliases
const condition = nob.isEmpty()
const condition = nob.notExist()

NotEmptyCondition

src/condition/notEmpty.ts

Only return pages where the page property value is present.

new NotEmptyCondition()

Extends Condition

Example
const condition = nob.notEmpty()

// aliases
const condition = nob.isNotEmpty()
const condition = nob.exists()

Only return pages where the page property value contains the provided value.

new ContainCondition(params: ((string | number) | Array<(string | number)>))

Extends Condition

Parameters
params (((string | number) | Array<(string | number)>)) the condition value
Example
const condition = nob.contain('Bridge')
const condition = nob.contain(['Bridge', 'Moat'])

// aliases
const condition = nob.contains('Bridge')
const condition = nob.has('Bridge')
const condition = nob.include('Bridge')
const condition = nob.includes('Bridge')

NotContainCondition

src/condition/notContain.ts

Only return pages where the page property value does not contain the provided value.

new NotContainCondition(params: ((string | number) | Array<(string | number)>))

Extends Condition

Parameters
params (((string | number) | Array<(string | number)>)) the condition value
Example
const condition = nob.notContain('Bridge')
const condition = nob.notContain(['Bridge', 'Moat'])

// aliases
const condition = nob.notContains('Bridge')
const condition = nob.doesNotContain('Bridge')
const condition = nob.hasNot('Bridge')
const condition = nob.exclude('Bridge')
const condition = nob.excludes('Bridge')

StartsWithCondition

src/condition/startsWith.ts

Only return pages where the page property value starts with the provided value.

new StartsWithCondition(params: (string | Array<string>))

Extends Condition

Parameters
params ((string | Array<string>)) the condition value
Example
const condition = nob.startsWith('Bridge')
const condition = nob.startsWith(['Bridge', 'Moat'])

EndsWithCondition

src/condition/endsWith.ts

Only return pages where the page property value ends with the provided value.

new EndsWithCondition(params: (string | Array<string>))

Extends Condition

Parameters
params ((string | Array<string>)) the condition value
Example
const condition = nob.endsWith('Bridge')
const condition = nob.endsWith(['Bridge', 'Moat'])

GreaterThanCondition

src/condition/greaterThan.ts

Only return pages where the page property value is greater than the provided value.

new GreaterThanCondition(params: (number | Array<number>))

Extends Condition

Parameters
params ((number | Array<number>)) the condition value
Example
const condition = nob.greaterThan(12)

// aliases
const condition = nob.gt(12)
const condition = nob.moreThan(12)

GreaterThanOrEqualToCondition

src/condition/greaterThanOrEqualTo.ts

Only return pages where the page property value is greater than or equal to the provided value.

new GreaterThanOrEqualToCondition(params: (number | Array<number>))

Extends Condition

Parameters
params ((number | Array<number>)) the condition value
Example
const condition = nob.greaterThanOrEqualTo(12)

// aliases
const condition = nob.gte(12)
const condition = nob.moreThanOrEqualTo(12)

LessThanCondition

src/condition/lessThan.ts

Only return pages where the page property value is less than the provided value.

new LessThanCondition(params: (number | Array<number>))

Extends Condition

Parameters
params ((number | Array<number>)) the condition value
Example
const condition = nob.lessThan(12)

// aliases
const condition = nob.lt(12)

LessThanOrEqualToCondition

src/condition/lessThanOrEqualTo.ts

Only return pages where the page property value is less than or equal to the provided value.

new LessThanOrEqualToCondition(params: (number | Array<number>))

Extends Condition

Parameters
params ((number | Array<number>)) the condition value
Example
const condition = nob.lessThanOrEqualTo(12)

// aliases
const condition = nob.lte(12)

Only return pages where the page property value is before the provided date. If a date with a time is provided, the comparison is done with millisecond precision. Note that if no timezone is provided, the default is UTC.

new BeforeCondition(params: ((string | Date) | Array<(string | Date)>))

Extends Condition

Parameters
params (((string | Date) | Array<(string | Date)>)) the condition value
Example
const condition = nob.before('2023-01-01')
const condition = nob.before(new Date(2023, 0, 1))

OnOrBeforeCondition

src/condition/onOrBefore.ts

Only return pages where the page property value is on or before the provided date. If a date with a time is provided, the comparison is done with millisecond precision. Note that if no timezone is provided, the default is UTC.

new OnOrBeforeCondition(params: ((string | Date) | Array<(string | Date)>))

Extends Condition

Parameters
params (((string | Date) | Array<(string | Date)>)) the condition value
Example
const condition = nob.onOrBefore('2023-01-01')
const condition = nob.onOrBefore(new Date(2023, 0, 1))

OnOrBeforeCondition

src/condition/onOrbefore.ts

Only return pages where the page property value is on or before the provided date. If a date with a time is provided, the comparison is done with millisecond precision. Note that if no timezone is provided, the default is UTC.

new OnOrBeforeCondition(params: ((string | Date) | Array<(string | Date)>))

Extends Condition

Parameters
params (((string | Date) | Array<(string | Date)>)) the condition value
Example
const condition = nob.onOrBefore('2023-01-01')
const condition = nob.onOrBefore(new Date(2023, 0, 1))

Only return pages where the page property value is after the provided date. If a date with a time is provided, the comparison is done with millisecond precision. Note that if no timezone is provided, the default is UTC.

new AfterCondition(params: ((string | Date) | Array<(string | Date)>))

Extends Condition

Parameters
params (((string | Date) | Array<(string | Date)>)) the condition value
Example
const condition = nob.after('2023-01-01')
const condition = nob.after(new Date(2023, 0, 1))

OnOrAfterCondition

src/condition/onOrAfter.ts

Only return pages where the page property value is on or after the provided date. If a date with a time is provided, the comparison is done with millisecond precision. Note that if no timezone is provided, the default is UTC.

new OnOrAfterCondition(params: ((string | Date) | Array<(string | Date)>))

Extends Condition

Parameters
params (((string | Date) | Array<(string | Date)>)) the condition value
Example
const condition = nob.onOrAfter('2023-01-01')
const condition = nob.onOrAfter(new Date(2023, 0, 1))

OnOrAfterCondition

src/condition/onOrafter.ts

Only return pages where the page property value is on or after the provided date. If a date with a time is provided, the comparison is done with millisecond precision. Note that if no timezone is provided, the default is UTC.

new OnOrAfterCondition(params: ((string | Date) | Array<(string | Date)>))

Extends Condition

Parameters
params (((string | Date) | Array<(string | Date)>)) the condition value
Example
const condition = nob.onOrAfter('2023-01-01')
const condition = nob.onOrAfter(new Date(2023, 0, 1))

PastWeekCondition

src/condition/pastWeek.ts

Only return pages where the page property value is within the past week.

new PastWeekCondition()

Extends Condition

Example
const condition = nob.pastWeek()

PastMonthCondition

src/condition/pastMonth.ts

Only return pages where the page property value is within the past month.

new PastMonthCondition()

Extends Condition

Example
const condition = nob.pastMonth()

PastYearCondition

src/condition/pastYear.ts

Only return pages where the page property value is within the past year.

new PastYearCondition()

Extends Condition

Example
const condition = nob.pastYear()

ThisWeekCondition

src/condition/thisWeek.ts

Only return pages where the page property value is within the current week. The current week starts on the most recent Sunday and ends on the upcoming Saturday.

new ThisWeekCondition()

Extends Condition

Example
const condition = nob.thisWeek()

NextWeekCondition

src/condition/nextWeek.ts

Only return pages where the page property value is within the next week.

new NextWeekCondition()

Extends Condition

Example
const condition = nob.nextWeek()

NextMonthCondition

src/condition/nextMonth.ts

Only return pages where the page property value is within the next month.

new NextMonthCondition()

Extends Condition

Example
const condition = nob.nextMonth()

NextYearCondition

src/condition/nextYear.ts

Only return pages where the page property value is within the next year.

new NextYearCondition()

Extends Condition

Example
const condition = nob.nextYear()

Sorting

Utility functions for Sort

A sort is a condition used to order the entries returned from a database query. A database query can be sorted by a property and/or timestamp and in a given direction. For example, a library database can be sorted by the "Name of a book" (i.e. property) and in ascending (i.e. direction).

new Sort(property: (string | SortTimeType), direction: SortDirection)
Parameters
property ((string | SortTimeType)) the database field
direction (SortDirection = descending) the sort direction
Example
const sort = nob.sort('published_at')
const sort = nob.sort('created_time', 'ascending')
const sort = nob.sort('last_edited_time', 'ascending')
Instance Members
toJson()

Appendix

TermFilter is a base class which represents all filters that take conditions as arguments

new TermFilter(property: string, conditions: (Condition | Array<Condition>), filterType: string, termFilterType: TermFilterType)

Extends Filter

Parameters
property (string) the database field which this filter will be applied
conditions ((Condition | Array<Condition>)) one or more conditions for this filter
filterType (string) certain filters can have variations eg TextFilter can be either title, rich_text etc
termFilterType (TermFilterType) determines whether this is a propertyFilter or a timestampFilter
Instance Members
transform(value)
getProperty()
getFilterType()
getTermFilterType()
toJson()

TermFilterType

src/filter/types.ts

TermFilter types

TermFilterType

Type: ("property" | "timestamp")

Example
// when "property"
{
  property: 'field',
  ...
}

// when "timestamp"
{
  timestamp: 'field',
  ...
}

TextFilterCondition

src/filter/text.ts

Possible conditions to be used with TextFilter

TextFilterCondition

Type: (EqualCondition<string> | NotEqualCondition<string> | ContainCondition<string> | NotContainCondition<string> | StartsWithCondition<string> | EndsWithCondition<string> | EmptyCondition | NotEmptyCondition)

TextPropertyFilterType

src/filter/text.ts

Possible filter types to be used with TextFilter

TextPropertyFilterType

Type: ("title" | "rich_text" | "url" | "email" | "phone_number")

TextFilterObject

src/filter/text.ts

JSON representation of the TextFilter

TextFilterObject

Type: (TextPropertyFilterObject<(string | Array<string>)> | TextPropertyFilterObject<boolean>)

NumberFilterCondition

src/filter/number.ts

Possible conditions to be used with NumberFilter

NumberFilterCondition

Type: (EqualCondition<number> | NotEqualCondition<number> | GreaterThanCondition<number> | GreaterThanOrEqualToCondition<number> | LessThanCondition<number> | LessThanOrEqualToCondition<number> | EmptyCondition | NotEmptyCondition)

NumberFilterObject

src/filter/number.ts

JSON representation of the NumberFilter

NumberFilterObject

Type: (NumberPropertyFilterObject<(number | Array<number>)> | NumberPropertyFilterObject<boolean>)

CheckboxFilterCondition

src/filter/checkbox.ts

Allowed conditions for checkboxFilter

CheckboxFilterCondition

Type: (EqualCondition<boolean> | NotEqualCondition<boolean>)

CheckboxFilterObject

src/filter/checkbox.ts

JSON representation of the checkboxFilter

CheckboxFilterObject

Type: CheckboxPropertyFilterObject<boolean>

SelectFilterCondition

src/filter/select.ts

Possible conditions to be used with SelectFilter

SelectFilterCondition

Type: (EqualCondition<string> | NotEqualCondition<string> | EmptyCondition | NotEmptyCondition)

SelectFilterObject

src/filter/select.ts

JSON representation of the SelectFilter

SelectFilterObject

Type: (SelectPropertyFilterObject<(string | Array<string>)> | SelectPropertyFilterObject<boolean>)

MultiSelectFilterCondition

src/filter/multiSelect.ts

Possible conditions to be used with MultiSelectFilter

MultiSelectFilterCondition

Type: (ContainCondition<string> | NotContainCondition<string> | EmptyCondition | NotEmptyCondition)

MultiSelectFilterCondition

src/filter/multiselect.ts

Possible conditions to be used with MultiSelectFilter

MultiSelectFilterCondition

Type: (ContainCondition<string> | NotContainCondition<string> | EmptyCondition | NotEmptyCondition)

MultiSelectFilterObject

src/filter/multiSelect.ts

JSON representation of the MultiSelectFilter

MultiSelectFilterObject

Type: (MultiSelectPropertyFilterObject<(string | Array<string>)> | MultiSelectPropertyFilterObject<boolean>)

MultiSelectFilterObject

src/filter/multiselect.ts

JSON representation of the MultiSelectFilter

MultiSelectFilterObject

Type: (MultiSelectPropertyFilterObject<(string | Array<string>)> | MultiSelectPropertyFilterObject<boolean>)

StatusFilterCondition

src/filter/status.ts

Possible conditions to be used with StatusFilter

StatusFilterCondition

Type: (EqualCondition<string> | NotEqualCondition<string> | EmptyCondition | NotEmptyCondition)

StatusFilterObject

src/filter/status.ts

JSON representation of the StatusFilter

StatusFilterObject

Type: (StatusPropertyFilterObject<(string | Array<string>)> | StatusPropertyFilterObject<boolean>)

DateFilterCondition

src/filter/date.ts

Possible conditions to be used with DateFilter

DateFilterCondition

Type: (EqualCondition<(string | Date)> | BeforeCondition<(string | Date)> | OnOrBeforeCondition<(string | Date)> | AfterCondition<(string | Date)> | OnOrAfterCondition<(string | Date)> | PastWeekCondition | PastMonthCondition | PastYearCondition | ThisWeekCondition | NextWeekCondition | NextMonthCondition | NextYearCondition | EmptyCondition | NotEmptyCondition)

DateTimestampFilterType

src/filter/date.ts

filter type variants for DateFilter

DateTimestampFilterType

Type: ("date" | "created_time" | "last_edited_time")

Example
const filter = nob.DateFilter('blog', nob.after('2023-01-01'), 'created_time')

DateFilterObject

src/filter/date.ts

JSON representation of the DateFilter

DateFilterObject

Type: (DateTimestampFilterObject<(string | Array<string> | Date | Array<Date>)> | DateTimestampFilterObject<boolean> | DateTimestampFilterObject<Record<string, any>>)

PeoplePropertyFilterType

src/filter/people.ts

filter type variations for PeopleFilter

PeoplePropertyFilterType

Type: ("people" | "created_by" | "last_edited_by")

PeopleFilterCondition

src/filter/people.ts

Possible conditions to be used with PeopleFilter

PeopleFilterCondition

Type: (ContainCondition<string> | NotContainCondition<string> | EmptyCondition | NotEmptyCondition)

PeopleFilterObject

src/filter/people.ts

JSON representation of the PeopleFilter

PeopleFilterObject

Type: (PeoplePropertyFilterObject<(string | Array<string>)> | PeoplePropertyFilterObject<boolean>)

FilesFilterCondition

src/filter/files.ts

Possible conditions to be used with FilesFilter

FilesFilterCondition

Type: (EmptyCondition | NotEmptyCondition)

FilesFilterObject

src/filter/files.ts

JSON representation of the FilesFilter

FilesFilterObject

Type: FilesPropertyFilterObject<boolean>

RelationFilterCondition

src/filter/relation.ts

Possible conditions to be used with RelationFilter

RelationFilterCondition

Type: (ContainCondition<string> | NotContainCondition<string> | EmptyCondition | NotEmptyCondition)

RelationFilterObject

src/filter/relation.ts

JSON representation of the RelationFilter

RelationFilterObject

Type: (RelationPropertyFilterObject<(string | Array<string>)> | RelationPropertyFilterObject<boolean>)

RollUpFilterAggregationType

src/filter/rollUp.ts

Possible aggregation types for RollUpFilter

RollUpFilterAggregationType

Type: ("any" | "every" | "none" | "number" | "date")

RollUpFilterFilter

src/filter/rollUp.ts

Possible conditions to be used with RollUpFilter

RollUpFilterFilter

Type: (TextFilter | NumberFilter | DateFilter)

RollUpFilterObject

src/filter/rollUp.ts

JSON representation of the RollUpFilter

RollUpFilterObject

Type: any

FormulaFilterAggregationType

src/filter/formula.ts

Possible aggregation types for FormulaFilter

FormulaFilterAggregationType

Type: ("string" | "checkbox" | "number" | "date")

FormulaFilterFilter

src/filter/formula.ts

Possible conditions to be used with FormulaFilter

FormulaFilterFilter

Type: (TextFilter | CheckboxFilter | NumberFilter | DateFilter)

FormulaFilterObject

src/filter/formula.ts

JSON representation of the FormulaFilter

FormulaFilterObject

Type: any

CompoundFilterFilter

src/filter/compound.ts

Possible filters to use with Compoundfilter

CompoundFilterFilter

Type: (TextFilter | NumberFilter | CheckboxFilter | SelectFilter | MultiSelectFilter | StatusFilter | DateFilter | PeopleFilter | FilesFilter | RelationFilter | RollUpFilter | FormulaFilter)

CompoundFilterFilterRecursive

src/filter/compound.ts

Recursive to allow nesting a CompoundFilter within a CompoundFilter

CompoundFilterFilterRecursive

Type: (CompoundFilter | CompoundFilterFilter)

CompoundFilterFilterObject

src/filter/compound.ts

Possible filters objects to return with Compoundfilter

CompoundFilterFilterObject

Type: (TextFilterObject | NumberFilterObject | CheckboxFilterObject | SelectFilterObject | MultiSelectFilterObject | StatusFilterObject | DateFilterObject | PeopleFilterObject | FilesFilterObject | RelationFilterObject | RollUpFilterObject | FormulaFilterObject)

CompoundFilterObjectRecursive

src/filter/compound.ts

Recursive to allow nesting a CompoundFilter within a CompoundFilter

CompoundFilterObjectRecursive

Type: (CompoundFilterFilterObject | CompoundFilterObject)

CompoundFilterObject

src/filter/compound.ts

JSON representation of CompoundFilter

CompoundFilterObject

Type: {and: Array<CompoundFilterObjectRecursive>?, or: Array<CompoundFilterObjectRecursive>?}

Properties

FilterQueryFilter

src/query/filter.ts

Possible filters to use with FilterQuery

FilterQueryFilter

Type: (TextFilter | NumberFilter | CheckboxFilter | SelectFilter | MultiSelectFilter | StatusFilter | DateFilter | PeopleFilter | FilesFilter | RelationFilter | RollUpFilter | FormulaFilter | CompoundFilter)

FilterQueryFilterObject

src/query/filter.ts

JSON representation of FilterQuery

FilterQueryFilterObject

Type: (TextFilterObject | NumberFilterObject | CheckboxFilterObject | SelectFilterObject | MultiSelectFilterObject | StatusFilterObject | DateFilterObject | PeopleFilterObject | FilesFilterObject | RelationFilterObject | RollUpFilterObject | FormulaFilterObject | CompoundFilterObject)

The base class for all conditions.

new Condition(property: string, params: (T | Array<T>))
Parameters
property (string) the condition name
params ((T | Array<T>)) the condition value
Instance Members
toJson()
SortBase

Type: {direction: SortDirection}

Properties
direction (SortDirection)

SortProperty

src/sort/types.ts
SortProperty

Type: any

SortTimeType

src/sort/types.ts
SortTimeType

Type: ("created_time" | "last_edited_time")

SortTime

Type: any