--- layout: docs title: Matcher edit_url: "https://github.com/nylas/N1/blob/master/src/flux/attributes/matcher.coffee" ---

Summary

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 DatabaseStore. Each matcher has a reference to a model attribute, a comparator and a value.


# Retrieving Matchers

isUnread = Thread.attributes.unread.equal(true)

hasLabel = Thread.attributes.lables.contains('label-id-123')

# Using Matchers in Database Queries

DatabaseStore.findAll(Thread).where(isUnread)...

# Using Matchers to test Models

threadA = new Thread(unread: true)
threadB = new Thread(unread: false)

isUnread.evaluate(threadA)
# => true
isUnread.evaluate(threadB)
# => false