1
ruby 드라이버에서 mongodb로 콜렉션 업데이트를 호출하고 리턴 코드 117을 얻습니다. 일반적으로 얻은 오류 코드는 어떻게 해석합니까?MongoDB 리턴 코드 의미 (루비 드라이버)
ruby 드라이버에서 mongodb로 콜렉션 업데이트를 호출하고 리턴 코드 117을 얻습니다. 일반적으로 얻은 오류 코드는 어떻게 해석합니까?MongoDB 리턴 코드 의미 (루비 드라이버)
안전 모드를 사용하는 경우 update 메소드는 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}
이것은 문서에서 더 명확하게 할 수 있습니다. 나는 다음 루비 드라이버 릴리스를 위해 그것을 업데이트 할 것이다.
좋은 질문입니다. 나는 루비 드라이버의 소스 코드를 살펴보기 시작할 것이다. –
이 코드를 반환하는 스 니펫을 포함시킬 수 있습니까? –