datanoise / mongo.cr

Crystal binding for MongoDB C Driver
MIT License
97 stars 35 forks source link

Error when trying to retrieve value by key from BSON object #45

Open drum445 opened 5 years ago

drum445 commented 5 years ago

Below error when trying to retrieve value by key from a BSON object

Error in src/api.cr:8: instantiating 'Mongo::Collection#find(Hash(String, Hash(String, Int32)))'

collection.find({"age" => {"$gt" => 30}}) do |doc|
           ^~~~

in lib/mongo/src/mongo/collection.cr:133: instantiating 'Mongo::Cursor#each()'

    find(query, fields, flags, skip, limit, batch_size, prefs).each do |doc|
                                                               ^~~~

in lib/mongo/src/mongo/collection.cr:133: instantiating 'Mongo::Cursor#each()'

    find(query, fields, flags, skip, limit, batch_size, prefs).each do |doc|
                                                               ^~~~

in src/api.cr:8: instantiating 'Mongo::Collection#find(Hash(String, Hash(String, Int32)))'

collection.find({"age" => {"$gt" => 30}}) do |doc|
           ^~~~

in src/api.cr:10: instantiating 'BSON#[](String)'

  puts doc["age"]
          ^

in lib/mongo/src/bson.cr:127: instantiating 'fetch(String)'

    fetch(key) { raise IndexError.new }
    ^~~~~

in lib/mongo/src/bson.cr:116: instantiating 'BSON::Value#value()'

      Value.new(value).value
                       ^~~~~

in lib/mongo/src/bson/value.cr:42: undefined constant Time::Kind::Utc

        Time.new(spec, Time::Kind::Utc)