SearchBuilder
Fluent search builder for advanced event queries. Provides case-insensitive text search, metadata search, and more.
Example
Section titled “Example”// Get eventsconst events = cal.search() .text('christmas') .categories(['holiday']) .metadata({ season: 'advent' }) .dateFrom('2025-01-01') .dateTo('2025-12-31') .sortBy('date', 'asc') .getEvents();
// Get days containing matching eventsconst days = cal.search() .text('easter') .getDays();Type Parameters
Section titled “Type Parameters”TMetadata
Section titled “TMetadata”TMetadata extends Record<string, unknown> = Record<string, unknown>
Custom metadata type for events
TCategory
Section titled “TCategory”TCategory extends string = string
Category type for events
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SearchBuilder<
TMetadata,TCategory>(executor):SearchBuilder<TMetadata,TCategory>
Parameters
Section titled “Parameters”executor
Section titled “executor”(options) => CalendarEvent<TMetadata, TCategory>[]
Returns
Section titled “Returns”SearchBuilder<TMetadata, TCategory>
Methods
Section titled “Methods”categories()
Section titled “categories()”categories(
categories):this
Filter by categories (match any)
Parameters
Section titled “Parameters”categories
Section titled “categories”string[]
Returns
Section titled “Returns”this
category()
Section titled “category()”category(
category):this
Filter by category (single)
Parameters
Section titled “Parameters”category
Section titled “category”string
Returns
Section titled “Returns”this
count()
Section titled “count()”count():
number
Count matching events
Returns
Section titled “Returns”number
date()
Section titled “date()”date(
date):this
Filter by specific date
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
dateFrom()
Section titled “dateFrom()”dateFrom(
date):this
Filter events from this date onwards (inclusive, uses >=)
Parameters
Section titled “Parameters”string
Start date in YYYY-MM-DD format
Returns
Section titled “Returns”this
dateTo()
Section titled “dateTo()”dateTo(
date):this
Filter events up to this date (inclusive, uses <=)
Parameters
Section titled “Parameters”string
End date in YYYY-MM-DD format
Returns
Section titled “Returns”this
description()
Section titled “description()”description(
search):this
Search text in description only (case-insensitive)
Parameters
Section titled “Parameters”search
Section titled “search”string
Returns
Section titled “Returns”this
exists()
Section titled “exists()”exists():
boolean
Check if any events match the search criteria
Returns
Section titled “Returns”boolean
first()
Section titled “first()”first():
CalendarEvent<TMetadata,TCategory> |undefined
Get the first matching event or undefined
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory> | undefined
getDays()
Section titled “getDays()”getDays():
CalendarDay<TMetadata,TCategory>[]
Get calendar days containing matching events. Returns days with their events sorted by keyword match score (highest first), then by priority.
Returns
Section titled “Returns”CalendarDay<TMetadata, TCategory>[]
Array of calendar days containing matching events
Example
Section titled “Example”// Basic usage - get days with matching eventsconst days = cal.search().text('christmas').getDays();
// With typed calendar (generics flow automatically)const cal = calendary<LiturgicalMetadata>();const days = cal.search().category('holiday').getDays();// days[0].events[0].metadata?.rank is typed!getEvents()
Section titled “getEvents()”getEvents():
CalendarEvent<TMetadata,TCategory>[]
Get matching events with typed result. Returns only the events that match the search criteria.
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
Array of matching events
Example
Section titled “Example”// Basic usageconst events = cal.search().text('christmas').getEvents();
// With typed calendar (generics flow automatically)const cal = calendary<LiturgicalMetadata>();const events = cal.search().metadata({ rank: 'solemnity' }).getEvents();// events[0].metadata?.rank is typed!group()
Section titled “group()”group(
groupId):this
Filter by single group
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
Returns
Section titled “Returns”this
groups()
Section titled “groups()”groups(
groupIds):this
Filter by groups
Parameters
Section titled “Parameters”groupIds
Section titled “groupIds”string[]
Returns
Section titled “Returns”this
hasAllCategories()
Section titled “hasAllCategories()”hasAllCategories(
categories):this
Filter by categories (must have all)
Parameters
Section titled “Parameters”categories
Section titled “categories”string[]
Returns
Section titled “Returns”this
id(
search):this
Search text in id only (case-insensitive)
Parameters
Section titled “Parameters”search
Section titled “search”string
Returns
Section titled “Returns”this
keyword()
Section titled “keyword()”keyword(
keyword):this
Search by single keyword
Parameters
Section titled “Parameters”keyword
Section titled “keyword”string
Returns
Section titled “Returns”this
keywords()
Section titled “keywords()”keywords(
keywords):this
Search by keywords (match any)
Parameters
Section titled “Parameters”keywords
Section titled “keywords”string[]
Returns
Section titled “Returns”this
limit()
Section titled “limit()”limit(
count):this
Limit number of results
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
maxPriority()
Section titled “maxPriority()”maxPriority(
priority):this
Filter by maximum priority (higher = more important; default 0)
Parameters
Section titled “Parameters”priority
Section titled “priority”number
Returns
Section titled “Returns”this
metadata()
Section titled “metadata()”metadata(
query):this
Search by metadata key-value pairs. Supports nested objects and case-insensitive string matching.
Parameters
Section titled “Parameters”MetadataQuery<TMetadata>
Returns
Section titled “Returns”this
Example
Section titled “Example”// Simple key-value.metadata({ season: 'advent' })
// Nested object.metadata({ location: { country: 'fr' } })
// Multiple conditions (AND).metadata({ rank: 'solemnity', vestmentColor: 'white' })minPriority()
Section titled “minPriority()”minPriority(
priority):this
Filter by minimum priority (higher = more important; default 0)
Parameters
Section titled “Parameters”priority
Section titled “priority”number
Returns
Section titled “Returns”this
offset()
Section titled “offset()”offset(
count):this
Offset results (for pagination)
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
range()
Section titled “range()”range(
from,to):this
Filter by date range (inclusive on both ends)
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”this
sortBy()
Section titled “sortBy()”sortBy(
field,order?):this
Sort results by field and order
Parameters
Section titled “Parameters”order?
Section titled “order?”SortOrder = "asc"
Returns
Section titled “Returns”this
source()
Section titled “source()”source(…
source):this
Filter by source — match any (the plugin / feed / subscription that produced it).
Parameters
Section titled “Parameters”source
Section titled “source”…string[]
Returns
Section titled “Returns”this
status()
Section titled “status()”status(…
status):this
Filter by status — match any (e.g. hide cancelled by listing the ones you want).
Parameters
Section titled “Parameters”status
Section titled “status”…("confirmed" | "tentative" | "cancelled")[]
Returns
Section titled “Returns”this
text()
Section titled “text()”text(
search):this
Search text in title and description (case-insensitive)
Parameters
Section titled “Parameters”search
Section titled “search”string
Returns
Section titled “Returns”this
title()
Section titled “title()”title(
search):this
Search text in title only (case-insensitive)
Parameters
Section titled “Parameters”search
Section titled “search”string
Returns
Section titled “Returns”this
type()
Section titled “type()”type(…
types):this
Filter by event type(s) — match any (e.g. "weekly", "daily", a plugin type).
Parameters
Section titled “Parameters”…string[]
Returns
Section titled “Returns”this