Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Last active December 15, 2015 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1dolinski/5340517 to your computer and use it in GitHub Desktop.
Save 1dolinski/5340517 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mongo'
require 'pry'
require 'win32ole'

db = Mongo::Connection.new.db("test")
x = db['text']

y = x.find({a: {$gt: 0}})
y.each {|y| puts y }

{"_id"=>BSON::ObjectId('51630eea5a8d7b8a8be738c0'), "a"=>1.0} {"_id"=>BSON::ObjectId('51632de8583be71698000001'), "a"=>1} {"_id"=>BSON::ObjectId('51632de8583be71698000002'), "a"=>1, "b"=>2}

The Error

syntax error, unexpected ':', expecting tASSOC

# for this line at the $gt: part
y = x.find({a: {$gt: 0}})
y = x.find({'b' =>  {'$gt' => 0}})
y.each {|y| puts y }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment