Home Manual Reference Source Test
public class | source

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
public

muid: *

public

val: *

Method Summary

Public Methods
public

attribute(): *

public

evaluate(model: *): *

public

joinSQL(klass: *): boolean

public
public

value(): *

public

whereSQL(klass: *): string

Public Constructors

public constructor(attr: *, comparator: *, val: *) source

Params:

NameTypeAttributeDescription
attr *
comparator *
val *

Public Members

public attr: * source

public comparator: * source

public muid: * source

public val: * source

Public Methods

public attribute(): * source

Return:

*

public evaluate(model: *): * source

Params:

NameTypeAttributeDescription
model *

Return:

*

public joinSQL(klass: *): boolean source

Params:

NameTypeAttributeDescription
klass *

Return:

boolean

public joinTableRef(): string source

Return:

string

public value(): * source

Return:

*

public whereSQL(klass: *): string source

Params:

NameTypeAttributeDescription
klass *

Return:

string