Class: ExtJs::Mongo
- Inherits:
-
Object
- Object
- ExtJs::Mongo
- Defined in:
- lib/ruby-ext-js.rb
Constant Summary collapse
- DEFAULT_SKIP =
0
- MAX_LIMIT =
500
- DEFAULT_LIMIT =
50
Class Method Summary collapse
-
.allowed_filters ⇒ Array
Array of string values representing keys that are filterable.
-
.filter_opts ⇒ Object
Define options for specific filters.
Instance Method Summary collapse
-
#conditions ⇒ Hash
‘find()` conditions for `Mongo::Collection.find( conditions, opts )`.
-
#initialize(params) ⇒ Mongo
constructor
A new instance of Mongo.
-
#options ⇒ Hash
‘find()` options for `Mongo::Collection.find( conditions, opts )`.
Constructor Details
#initialize(params) ⇒ Mongo
Returns a new instance of Mongo.
74 75 76 77 78 79 |
# File 'lib/ruby-ext-js.rb', line 74 def initialize( params ) @params = {} params.each do |k, v| @params[k.to_s] = v end end |
Class Method Details
.allowed_filters ⇒ Array
Returns Array of string values representing keys that are filterable.
98 99 100 |
# File 'lib/ruby-ext-js.rb', line 98 def self.allowed_filters [] end |
.filter_opts ⇒ Object
Define options for specific filters. Eg:
{
"field_1" => { :all_caps => true },
"field_2" => { :operator => "$all" },
"field_3" => { :strip => "true" }
}
108 109 110 |
# File 'lib/ruby-ext-js.rb', line 108 def self.filter_opts {} end |
Instance Method Details
#conditions ⇒ Hash
Returns ‘find()` conditions for `Mongo::Collection.find( conditions, opts )`.
82 83 84 |
# File 'lib/ruby-ext-js.rb', line 82 def conditions self.class.filter_param( @params ) end |
#options ⇒ Hash
Returns ‘find()` options for `Mongo::Collection.find( conditions, opts )`.
87 88 89 90 91 92 93 94 95 |
# File 'lib/ruby-ext-js.rb', line 87 def opts = {} opts.merge! self.class.skip_param( @params ) opts.merge! self.class.limit_param( @params ) opts.merge! self.class.sort_param( @params ) opts end |