Module: CX::Mongo::Query

Defined in:
lib/cx/mongo_query/version.rb,
lib/cx/mongo_query/operators.rb

Defined Under Namespace

Modules: Postfix

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.and(*args) ⇒ Object

LOGICAL OPS



106
# File 'lib/cx/mongo_query/operators.rb', line 106

def and( *args ); { $and => args } end

.eq(attr, val) ⇒ Object

COMPARISON OPS



94
# File 'lib/cx/mongo_query/operators.rb', line 94

def eq(    attr, val   );  { attr.to_s => { $eq  => val  } } end

.ge(attr, val) ⇒ Object



97
# File 'lib/cx/mongo_query/operators.rb', line 97

def ge(    attr, val   );  { attr.to_s => { $gte => val  } } end

.gt(attr, val) ⇒ Object



96
# File 'lib/cx/mongo_query/operators.rb', line 96

def gt(    attr, val   );  { attr.to_s => { $gt  => val  } } end

.in(attr, *vals) ⇒ Object



100
# File 'lib/cx/mongo_query/operators.rb', line 100

def in(    attr, *vals );  { attr.to_s => { $in  => vals } } end

.in_s(attr, str) ⇒ Object



102
# File 'lib/cx/mongo_query/operators.rb', line 102

def in_s(  attr, str   );  { attr.to_s => { $in  => str  } } end

.le(attr, val) ⇒ Object



99
# File 'lib/cx/mongo_query/operators.rb', line 99

def le(    attr, val   );  { attr.to_s => { $lte => val  } } end

.lt(attr, val) ⇒ Object



98
# File 'lib/cx/mongo_query/operators.rb', line 98

def lt(    attr, val   );  { attr.to_s => { $lt  => val  } } end

.ne(attr, val) ⇒ Object



95
# File 'lib/cx/mongo_query/operators.rb', line 95

def ne(    attr, val   );  { attr.to_s => { $ne  => val  } } end

.nin(attr, *vals) ⇒ Object



101
# File 'lib/cx/mongo_query/operators.rb', line 101

def nin(   attr, *vals );  { attr.to_s => { $nin => vals } } end

.nin_s(attr, str) ⇒ Object



103
# File 'lib/cx/mongo_query/operators.rb', line 103

def nin_s( attr, str   );  { attr.to_s => { $nin => str  } } end

.nor(*args) ⇒ Object

one or more query args



108
# File 'lib/cx/mongo_query/operators.rb', line 108

def nor( *args ); { $nor => args } end

.not(arg) ⇒ Object

single query argument only



109
# File 'lib/cx/mongo_query/operators.rb', line 109

def not( arg   ); { $not => arg  } end

.or(*args) ⇒ Object

one or more query args



107
# File 'lib/cx/mongo_query/operators.rb', line 107

def or(  *args ); { $or  => args } end

.rx(pattern, *qualifiers) ⇒ Object

REGEX EXPRESSION



112
113
114
115
116
# File 'lib/cx/mongo_query/operators.rb', line 112

def rx(pattern, *qualifiers)
  r = { $regex => pattern }
  qualifiers.each {|q| r.merge!(q)}
  r
end

.rxo(string) ⇒ Object

REGEX OPTIONS



119
120
121
# File 'lib/cx/mongo_query/operators.rb', line 119

def rxo(string)
  { $options => string.to_s }
end