collectype / factory/queries/queryEntry / queryEntryFactory
queryEntryFactory<
T,C>(ctx,oper): <K>(field,target) =>C
Defined in: factory/queries/queryEntry.ts:39
Creates a predicate filter for query entry checks using PredicType.query.entry.
T
The item type in the collection.
C extends Wherable<T, C>
The Wherable context type (must extend Wherable<T, C>).
C
The context (usually a collection) supporting the where method.
QueryEntryOper
The query entry operation to perform.
Returns a function that takes a query field on T, checks an entry, and filters the context.
<K>(field, target) => C
// Example: query entry filter with URLSearchParams
import { BaseFunctions, queryEntryFactory } from 'collectype';
type Post = { id: number; query: URLSearchParams };
class PostFunctions extends BaseFunctions<Post> {
queryContainsEntry = queryEntryFactory<Post, this>(this, 'contains_entry');
}
const posts: Post[] = [
{ id: 1, query: new URLSearchParams('tag=ts&tag=ai') },
{ id: 2, query: new URLSearchParams('q=docs') }
];
const fn = new PostFunctions(posts);
const filtered = fn.queryContainsEntry('query', ['tag', 'ai']);
// filtered contains items where query has the ['tag', 'ai'] entry
URL and URLSearchParams.PredicType.query.entry.