1
我從紅寶石驅動程序調用集合更新的MongoDB,並得到一個返回碼117 如何解釋一般,我得到了錯誤代碼?MongoDB的返回代碼含義(Ruby驅動程序)
我從紅寶石驅動程序調用集合更新的MongoDB,並得到一個返回碼117 如何解釋一般,我得到了錯誤代碼?MongoDB的返回代碼含義(Ruby驅動程序)
如果您正在使用安全模式,更新方法返回一個包含GetLastError函數的輸出的哈希值。但是,當你不使用安全模式下,我們簡單地返回被髮送到服務器的字節數。
# setup connection & get handle to collection
connection = Mongo::Connection.new
collection = connection['test']['test']
# remove existing documents
collection.remove
=> true
# insert test document
collection.insert(:_id => 1, :a => 1)
=> 1
collection.find_one
=> {"_id"=>1, "a"=>1}
# we sent a message with 64 bytes to a mongod
collection.update({_id: 1},{a: 2.0})
=> 64 # number of bytes sent to server
# with safe mode we updated one document -- output of getLastError command
collection.update({_id: 1},{a: 3.0}, :safe => true)
=> {"updatedExisting"=>true, "n"=>1, "connectionId"=>19, "err"=>nil, "ok"=>1.0}
這是可以在文檔中更清晰的東西。我會更新它的下一個紅寶石驅動程序版本。
好問題。我會開始查看Ruby驅動程序的源代碼。 –
你可以包括你的代碼返回這個片段? –