ColdMVC

Operators

ColdMVC has the following operators that can be used with the findBy(), findAllBy(), findWhere(), findAllWhere(), countBy(), countWhere(), and createQuery() methods on your models.

  • equal
  • notEqual
  • like
  • notLike
  • in
  • notIn
  • startsWith
  • notStartsWith
  • endsWith
  • notEndsWith
  • isNull
  • isNotNull
  • greaterThan
  • greaterThanEquals
  • lessThan
  • lessThanEquals
  • before
  • after
  • onOrBefore
  • onOrAfter

Examples:

_Book.findByTitleLike("Da Vinci Code");

_Book.findAllByTitleLike("Da Vinci Code");

_Book.countByTitleLike("Da Vinci Code");

_Book.findWhere({
    title = [ "like", "Da Vinci Code" ] 
});

_Book.findAllWhere({
    title = [ "like", "Da Vinci Code" ] 
});

_Book.countWhere({
    title = [ "like", "Da Vinci Code" ] 
});

In addition, the following operators are aliased when working with createQuery() for shorter method names.

  • eq: equal
  • neq: notEqual
  • gt: greaterThan
  • gte: greaterThanEquals
  • lt: lessThan
  • lte: lessThanEquals

Examples:

var q = _Book.createQuery();

q.where(
    q.eq("author", "Dan Brown"),
    q.like("title", "Da Vinci Code")        
);

var books = q.list();