Coder Social home page Coder Social logo

origin's Introduction

Origin

This is the legacy repository of the Origin gem, which has been merged into the official Mongoid codebase after version 2.2.0. You can find the code in the MongoDB Mongoid repository here.

The legacy README for Origin can be found here.

origin's People

Contributors

amarshall avatar arthurnn avatar dnd avatar durran avatar estolfo avatar flexoid avatar goshacmd avatar hanshasselberg avatar misfo avatar potatosalad avatar rodrigosaito avatar timoschilling avatar wyattisimo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

origin's Issues

undefined method rename

Unable to do renaming of fields to all documents in a collection
for eg:-
Subscriber.all.rename(:home_number => :home_numbers)
OR
Subscriber.where(:home_number => '9876543210').rename(:home_number => :home_numbers)
NoMethodError: undefined method rename' for #<Array:0xc28f184> from /home/jai/cellvoice_gits/current/r2i-web/vendor/ruby/1.9.1/gems/mongoid-2.4.12/lib/mongoid/criteria.rb:385:inmethod_missing'
from (irb):45

Add $nor selection

Syntax:

  Model.nor(field: 1, field: 2)
  Model.query(:field.nor => [ { field: 1 }, { field: 2 } ])

All $all selection

Syntax:

  Model.all(field: [ 1, 2, 3 ])
  Model.query(:field.all => [ 1, 2, 3 ])

Add $in selection

Syntax:

  Model.in(field: [ 1, 2 ])
  Model.query(:field.in => [ 1, 3 ])

'.not' isn't negating query

I'm sorry to bother, but I'm not sure if I am missing some of the Mongoid/Origin functionality. I'm trying to run a negation on a '.where' query but it doesn't seem to produce a negated result. I have a model called user:

class User
  include Mongoid::Document
  field :userid
  field :fname
  field :lname
end

However when I attempt to query from the Rails console

User.not.where(fname: "Aaron").selector
 => {"fname"=>"Aaron"}

User.where(fname: "Aaron").selector
 => {"fname"=>"Aaron"} 

And it seems as if the selector isn't producing the expected { "$not" => { "fname" => "Aaron" }} result for negation. Am I missing something? Or do I have a faulty setting? I'm running mongoid (3.0.1), moped (1.1.5), and origin (1.0.4).

Thanks!

Add #between selection

Syntax:

  Model.between(field: first...last)
  Model.query(:field.between => first...last)

equality on Origin::Key objects

{ :foo.all => [1, 2] } == { :foo.all => [1, 2] } #=> false

This should be true so (for instance) mocks in tests work correctly.

ReplicaSet Config schema since 2.4.6

I am a bit puzzled on what has changed from previous version to this one. I updated my bundle this morning from mongoid 2.4.5 and mongo 1.6.0 to mongoid 2.4.6 and mongo 1.6.1.
SInce that time I see the following errors/warnings in on my production server:

Initiating a ReplSetConnection with seeds passed as individual [host, port] array arguments is deprecated.
Please specify hosts as an array of 'host:port' strings; the old format will be removed in v2.0
max_retries_on_connection_failure is not a valid option for Mongo::ReplSetConnection
hosts is not a valid option for Mongo::ReplSetConnection
database is not a valid option for Mongo::ReplSetConnection

My mongoid.yml looks as:
production:
database: xxxx
hosts:

  • - s1
    • 27017
  • - s2
    • 27017
  • - s3
    • 27017
      read: :secondary

That produces the warnings ..
Changed also to:
max_retries_on_connection_failure: 5
logger: false
database: xxx
hosts: [[s1, 27017], [s2, 27017], [s3, 27017]]
read: :secondary

Didn't change anything.

So what is the current configuration schema. The mongoid.org docs request the above schema.
By the way, I am on ree-1.8.7-2012.01 and RoR 3.2.2 and MongoDB 2.0.2

Any hint is appreciated.

Txs

Remove Options Support

This should be specific to the framework using Moped, since the options vary by driver.

Weird stuff with 1.0.5

/Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/extensions/nil_class.rb:30:in __expanded__': wrong number of arguments (0 for 1) (ArgumentError) from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/mergeable.rb:199:inprepare'
from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/mergeable.rb:158:in block in __override__' from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/selectable.rb:597:inblock (2 levels) in selection'
from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/selectable.rb:596:in each_pair' from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/selectable.rb:596:inblock in selection'
from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/selectable.rb:594:in tap' from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/selectable.rb:594:inselection'
from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/mergeable.rb:156:in __override__' from /Users/peter/.rvm/gems/ruby-1.9.3-p194/gems/origin-1.0.5/lib/origin/selectable.rb:261:inne'
from (eval):2:in `excludes'
from /Users/peter/Development/nulay

it works fine if I use 1.0.4.. I am also using mongoid 3.0.3 and moped 1.2.0

BUG? Mergeable#__multi__ is prematurely converting Criteria to Documents

I've encountered what I think might be a bug in Origin. See the stack trace at the bottom of this ticket.

I'm arriving at it through a slightly unusual set of CanCan abilities, but I don't think they are the issue.

A minimal app demonstrating the problem is here: https://github.com/al/mongoid_cancan_bug. To reproduce run:

$ bundle && rake db:seeds && rails s

Then visit http://localhost:3000/profiles.json. You should see the error.

It arises from the fact that I have two applicable rules in abilities.rb. This is easily confirmed by removing one or other of the rules.

Digging through the stack trace lead me to this line in the Mergeable#__multi__ method.

The method is receiving an array of Criteria, however as soon as flatten is applied the Criteria are being resolved to actual matching documents (in this case Profile). This seems to surprise the rest of the method which evidently expects to still have an array of Criteria.

Removing the flatten will progress execution to line 134, where something similar seems to be happening.

Is this a bug or is there something unacceptable about the Criteria I am sending Mongoid/Origin's way via my CanCan abilities?

Cheers

NoMethodError (undefined method `inject' for #<Profile:0x007fbff1df7b28>):
  mongoid (3.0.9) lib/mongoid/attributes.rb:225:in `method_missing'
  origin (1.0.9) lib/origin/mergeable.rb:137:in `block (2 levels) in __multi__'
  origin (1.0.9) lib/origin/mergeable.rb:132:in `each'
  origin (1.0.9) lib/origin/mergeable.rb:132:in `block in __multi__'
  origin (1.0.9) lib/origin/mergeable.rb:130:in `tap'
  origin (1.0.9) lib/origin/mergeable.rb:130:in `__multi__'
  origin (1.0.9) lib/origin/selectable.rb:382:in `or'
  cancan (1.6.8) lib/cancan/model_adapters/mongoid_adapter.rb:38:in `block in database_records'
  cancan (1.6.8) lib/cancan/model_adapters/mongoid_adapter.rb:36:in `each'
  cancan (1.6.8) lib/cancan/model_adapters/mongoid_adapter.rb:36:in `inject'
  cancan (1.6.8) lib/cancan/model_adapters/mongoid_adapter.rb:36:in `database_records'
  cancan (1.6.8) lib/cancan/model_additions.rb:23:in `accessible_by'
  cancan (1.6.8) lib/cancan/controller_resource.rb:81:in `load_collection'
  cancan (1.6.8) lib/cancan/controller_resource.rb:34:in `load_resource'
  cancan (1.6.8) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
  cancan (1.6.8) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
  activesupport (3.2.6) lib/active_support/callbacks.rb:429:in `_run__3279536705548101580__process_action__1827249083152788164__callbacks'
  activesupport (3.2.6) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.6) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.6) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.6) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.6) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.6) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.6) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.6) lib/action_controller/metal/params_wrapper.rb:206:in `process_action'
  actionpack (3.2.6) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.6) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.6) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.6) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.6) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.6) lib/action_dispatch/routing/route_set.rb:600:in `call'
  mongoid (3.0.9) lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
  mongoid (3.0.9) lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
  mongoid (3.0.9) lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/cookies.rb:338:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.6) lib/active_support/callbacks.rb:405:in `_run__1299298641735140605__call__2567670475171850287__callbacks'
  activesupport (3.2.6) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.6) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.6) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.6) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.6) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.6) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.6) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.6) lib/rails/engine.rb:479:in `call'
  railties (3.2.6) lib/rails/application.rb:220:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.6) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /Users/alan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
  /Users/alan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
  /Users/alan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'


  Rendered /Users/alan/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.5ms)
  Rendered /Users/alan/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
  Rendered /Users/alan/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (8.6ms)

Add $mod selection

Syntax:

  Model.mod(field: [ 10, 1 ])
  Model.query(:field.mod => [ 10, 1 ])

Add Sorting Options

Add options for sorting:

Model.asc(:field)
Model.ascending(:field)
Model.desc(:field)
Model.descending(:field)
Model.order_by("field asc, other desc")
Model.order_by(:field.asc, :other.desc)
Model.order_by(field: :asc, other: :desc)

Error when using forwarding

From the example in the docs.

1.9.3-p194 :001 > require 'origin'
true
1.9.3-p194 :002 > class Query
1.9.3-p194 :003?>     include Origin::Queryable
1.9.3-p194 :004?>   end
Query < Object
1.9.3-p194 :005 > 
1.9.3-p194 :006 >   class Band
1.9.3-p194 :007?>     extend Origin::Forwardable
1.9.3-p194 :008?>     select_with :query
1.9.3-p194 :009?>   
1.9.3-p194 :010 >       def self.query
1.9.3-p194 :011?>         Query.new
1.9.3-p194 :012?>       end
1.9.3-p194 :013?>   end
NoMethodError: undefined method `delegate' for #<Class:Band>

Block-Based Query Syntax

Feature Suggestion:

Support block-based query syntax a la Squeel.

Article.where{created_at >= 2.weeks.ago}

In addition to normal hash-based query syntax.

Article.where(:created_at.gte => 2.weeks.ago)

batch_size is ignored

It seems batch_size option is ignored in mongoid/origin.

i = 0; Sample.all.batch_size(2).each {|s| i += 1; Rails.logger.info(i); break if i > 1100}

Looking at rails log I would expect seeing GET MORE command every two documents, instead I see only one after 101 document (MongoDB default behavior). Like this:

  MOPED: 127.0.0.1:27017 QUERY        database=amw_development collection=samples selector={} flags=[] limit=0 skip=0 fields=nil (48.2831ms)
1
2
...
101
  MOPED: 127.0.0.1:27017 GET_MORE     database=amw_development collection=samples limit=0 cursor_id=1976664482462204574 (1515.9869ms)
102
...
1100
1101

Note that I set the batch size to 2 only for the purpose of this example. In my app I tried it with a value of 100.

This is a pretty big issue for me as my sample processing times out when I crunch through 1000 samples without touching the cursor. I don't want to set the no-timeout option on the cursor to avoid risking memory leaks if my app dies.

elem_match with lte produces incorrect selector

From mongoid/mongoid#2206

Vote.where(:"versions".elem_match => { :updated_at.lte => Time.now.utc})
=> #<Mongoid::Criteria
   selector: {"versions"=>{"$elemMatch"=>{#<Origin::Key:0x00000004ef1b50 @name=:updated_at, @strategy=:__override__, @operator="$lte", @expanded=nil, @block=nil>=>2012-07-17 08:12:34 UTC}}},
   options:  {},
   class:    Vote,
   embedded: false>

This return empty results

Vote.where(:"versions".elem_match => { :updated_at => { :$lte => Time.now.utc} })
=> #<Mongoid::Criteria
   selector: {"versions"=>{"$elemMatch"=>{:updated_at=>{:$lte=>2012-07-17 08:12:44 UTC}}}},
   options:  {},
   class:    Vote,
   embedded: false>

This however returns correct result. Is it no longer possible to use first approach ?

Add $where selection

Syntax:

  Model.where("this.field > 4")
  Model.query("$where" => "this.field > 4")

Add $not negation

Syntax:

  Model.not.all(field: [ 1, 2, 3 ])
  Model.not.query(:field.all => [ 1, 2, 3 ])

Add $orderby Option

Syntax:

  Model.order_by([[ :name, :asc ], [ :title, :desc ]])
  Model.asc(:name)
  Model.ascending(:name)
  Model.desc(:name)
  Model.descending(:name)

UTC conversions in queries

(Note: I opened #2093 a bit ago thinking I had tracked this issue down, but that turned out to be a bug in my reproduction and I closed it. I think I've got it now though.)

When you provide Mongoid 3 with a DateTime, it converts it to UTC if you're using use_utc. However, the conversion seems to ignore whether the time is already in UTC:

Mongoid.use_utc = true

class Post
  include Mongoid::Document
  field :time, type: DateTime
end

puts "Current time in UTC: #{DateTime.now.utc}"

Post.create(time: DateTime.now).save!

an_hour_ago = DateTime.now - 1.hour

#express the time in the local zone
puts Post.where(time: {"$gt" => an_hour_ago}).empty?

#be explicit about being in UTC
puts Post.where(time: {"$gt" => an_hour_ago.utc}).empty?

In 2.4, I get this output:

Current time in UTC: 2012-06-11T03:33:21+00:00
MONGODB (0ms) repro2['system.namespaces'].find({})
MONGODB (0ms) repro2['$cmd'].find({:create=>"posts"}).limit(-1)
MONGODB (0ms) repro2['posts'].insert([{"_id"=>BSON::ObjectId('4fd567018ace235ee7000001'), "time"=>2012-06-11 03:33:21 UTC}])
MONGODB (0ms) repro2['posts'].find({:time=>{"$gt"=>2012-06-11 02:33:21 UTC}}, {:_id=>1}).limit(-1)
false
MONGODB (0ms) repro2['posts'].find({:time=>{"$gt"=>2012-06-11 02:33:21 UTC}}, {:_id=>1}).limit(-1)
false

It converts the local time into UTC time and leaves the UTC time as-is. But in 3.0.rc, I get this output:

Current time in UTC: 2012-06-11T03:32:59+00:00
  MOPED: localhost:27017 INSERT       database=repro3 collection=posts documents=[{"_id"=>4fd566eb8ace23735e000001, "time"=>2012-06-11 03:32:59 UTC}] flags=[] (0.0ms)
  MOPED: localhost:27017 COMMAND      database=repro3 command={:count=>:posts, :query=>{"time"=>{"$gt"=>2012-06-11 02:32:59 UTC}}} (0.0ms)
false
  MOPED: localhost:27017 COMMAND      database=repro3 command={:count=>:posts, :query=>{"time"=>{"$gt"=>2012-06-11 06:32:59 UTC}}} (0.0ms)
true

So it seems to be adding 4 hours (my UTC offset) to the time that's already in UTC, meaning it ends up querying for several hours ahead of what it should be.

Add Embedded Document Support to Aliasing

See mongoid/mongoid#2361

We can allow Origin to look at operations with a . in them, and check for aliases under a fully embedded tree... For example:

# In the provided aliases:
{ "addresses" => { "name" => "n" }}

# Then the query could alias "name" to "n":
queryable.where("addresses.name" => "Köpenicker Landstraße")

Add $or selection

Syntax:

  Model.or(field: 1, field: 2)
  Model.query(:field.or => [ { field: 1 }, { field: 2 } ])

Add capability for custom types to specify MongoDB query portions

Hi,

while working with money-mongoid project, I realized there is a need for custom types to generate portions of the MongoDB query directly (and not just serialize the type itself). E.g. when using a complex type like money (which consists of "cents", an Integer, and "currency_iso" a String) with comparison operators, the more natural way to express the query on a Product object having a field price of type Money is something along the lines of

Product.where(:price.gt => Money.new(2000,"USD"))

when only serializing the money object, the resulting query compares the cents value, ignoring the currency code, resulting in wrong results if the values in the DB are not all stored using the same currency.

In order to correctly perform the query the custom type should be able to actually generate the query subportion related to the price field such that it would look like

`{"price.cents" => {"$gt" => 2000}, "price.currency_iso" => "USD"}

I managed to implement such functionality by modifying the implementation of expr_querymethod of Selectable as a proof-of-concept (pls see custom_criteria_expansion branch of my fork of the origin project), but as an implementation it is a hack because it uses in Selectable the concept of serializers (defined in Queryable and some properties that "happen to be there" because the serializer is of type Mongoid::Field::Standard which is defined in the Mongoid gem.

So the changes should be possibly split between origin (either in Queryable or Selectableor both) and in mongoid (maybe introducing a Mongoid::Field::Custom class), but I leave to the more expert people the decision on where actually the changes should go, although I offer my help to implement such changes once there is an agreement on their correct place.

An example of how the Money type handles the query generation can be found here.

marco

Add $and selection

Syntax:

  Model.and(name: "test", title: "sir")
  Model.query(:field.and => [ { name: "test" }, { title: "sir" } ])

Add $gt, $gte, $lt, $lte selection

Syntax:

  Model.gt(field: 1)
  Model.query(:field.gt => 1)
  Model.gte(field: 1)
  Model.query(:field.gte => 1)
  Model.lt(field: 1)
  Model.query(:field.lt => 1)
  Model.lte(field: 1)
  Model.query(:field.lte => 1)

Add $slice option

Syntax:

  Model.slice(:addresses, 5)
  Model.slice(:addresses, -5)
  Model.slice(:addresses, [ 0, 10 ])

Allow for special case of using only(:a, :b, :c) i.c.w. without(:_id)

While mixing of field in- and exclusion is generally not allowed, one can explicitly exclude the _id field when providing a list of other fields to include. This is desirable when wanting to execute a query that is completely covered by an index which does not include the id field. In these cases, it must explicitly be excluded from the query.

A real-world use case: We have many users, some of which may have registered with their facebook account. We have an index on _id and a sparse index on facebook_id. We do not want to include _id in the latter in order to keep index size down. To quickly gather up all facebook_ids, we want to execute a covered query against the facebook_id index.

Current implementation: User.only(:facebook_id).tap { |q| q.options[:fields][:_id] = 0 }

Desired implementation: User.only(:facebook_id).without(:_id)

Selector values being evolved in-place

E.g:

class Foo
  include Mongoid::Document
  ALLOWED_VALUES = %w(a b).freeze
  field :f
end

> Foo.where(:f.in => Foo::ALLOWED_VALUES).count
RuntimeError: can't modify frozen Array
    from /Users/ben/.rvm/gems/ruby-1.9.3-p125@eqm/gems/origin-1.0.10/lib/origin/selector.rb:115:in `map!'
...

Seems wrong to be mutating the value passed in...

Add $elemMatch selection

Syntax:

  Model.elem_match(field: { a: 1, b: 5 })
  Model.query(:field.elem_match => { a: 1, b: 5 })

Add $nin selection

Syntax:

  Model.nin(field: [ 1, 2, 3 ])
  Model.query(:field.nin => [ 1, 2, 3 ])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.