collectype / factory/queries/queryValue / queryValueFactory
queryValueFactory<
T,C>(ctx,oper): <K>(field,target) =>C
Defined in: factory/queries/queryValue.ts:39
Creates a predicate filter for query value checks using PredicType.query.value.
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.
QueryValueOper
The query value operation to perform.
Returns a function that takes a query field on T, checks a value, and filters the context.
<K>(field, target) => C
// Example: query value filter with URLSearchParams
import { BaseFunctions, queryValueFactory } from 'collectype';
type Post = { id: number; query: URLSearchParams };
class PostFunctions extends BaseFunctions<Post> {
queryContainsValue = queryValueFactory<Post, this>(this, 'contains_value');
}
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.queryContainsValue('query', 'ai');
// filtered contains items whose query contains the value 'ai'
URL and URLSearchParams.PredicType.query.value.