collectype / factory/urls/urlOrigin / urlOriginFactory
urlOriginFactory<
T,C>(ctx,oper): <K>(field,target) =>C
Defined in: factory/urls/urlOrigin.ts:34
Creates a predicate filter for URL origin comparison using PredicType.url.origin.
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.
UrlOriginOper
The URL origin operation to perform.
Returns a function that takes a URL field on T, compares its origin, and filters the context.
<K>(field, target) => C
// Example based on sample/models/Person and sample/data/person
import { BaseFunctions, urlOriginFactory } from 'collectype';
import { Person } from '../../../sample/models/Person';
import { people } from '../../../sample/data/person';
class PersonFunctions extends BaseFunctions<Person> {
urlOriginStartsWith = urlOriginFactory<Person, this>(this, 'starts_with');
}
const fn = new PersonFunctions(people);
const filtered = fn.urlOriginStartsWith('website', 'https://person-');
// filtered contains people whose website origin starts with the target prefix
URL are supported.PredicType.url.origin.