Matcher
Direct Subclass:
lib/attributes/matcher.js~AndCompositeMatcher, lib/attributes/matcher.js~OrCompositeMatcher, lib/attributes/matcher.js~SearchMatcher
Indirect Subclass:
lib/attributes/matcher.js~NotCompositeMatcher
The Matcher class encapsulates a particular comparison clause on an Attribute. Matchers can evaluate whether or not an object matches them, and also compose SQL clauses for the RxDatabase. Each matcher has a reference to a model attribute, a comparator and a value. This class is heavily inspired by NSPredicate on Mac OS X / CoreData.
// Retrieving Matchers
const isUnread = Thread.attributes.unread.equal(true);
const hasLabel = Thread.attributes.categories.contains('label-id-123');
// Using Matchers in Database Queries
const db.findAll(Thread).where(isUnread)...
// Using Matchers to test Models
const threadA = new Thread({unread: true})
const threadB = new Thread({unread: false})
isUnread.evaluate(threadA)
// => true
isUnread.evaluate(threadB)
// => false
Constructor Summary
Public Constructor | ||
public |
constructor(attr: *, comparator: *, val: *) |
Member Summary
Public Members | ||
public |
attr: * |
|
public |
comparator: * |
|
public |
muid: * |
|
public |
val: * |
Method Summary
Public Methods | ||
public |
attribute(): * |
|
public |
evaluate(model: *): * |
|
public |
|
|
public |
|
|
public |
value(): * |
|
public |
|
Public Constructors
public constructor(attr: *, comparator: *, val: *) source
Params:
Name | Type | Attribute | Description |
attr | * | ||
comparator | * | ||
val | * |