使用ruby在Collection中插入文档

时间:2016-02-11 15:01:58

标签: ruby mongodb

我在下面的愚蠢简单的ruby / mongo代码中遇到了一个问题:

def initMongo
  @client.new(['127.0.0.1:27017'])
end

def creatDB(name)
  @database = @database.new(@client, name)
end

def creatCollection(name)
  @collection = @collection.new(@database, name)
  @collection.insert_one({name: 'test'})
  @collection.inspect
end

@collection.insert_one({name: 'test'})我得到:

  

/collection.rb:129:in write_concern&#39 ;: undefined method write_concern' for Mongo :: Client:Class

Ruby v2.2.3 Mongo v2.2

1 个答案:

答案 0 :(得分:0)

问题在于:

CURLOPT_INFILE

替换为:

def initMongo
  @client.new(['127.0.0.1:27017'])
end