2013-01-16 15 views
0

今天我試着$set一個DBRef與$db收集。這種情況是不是MongoDB服務器的bug?

但服務器說:「不okForForStorage」,所以操作失敗。

ps。我mongod版本是2.2

{ 
    "ts" : ISODate("2013-01-16T14:05:42.814Z"), 
    "op" : "update", 
    "ns" : "mydb.coll1", 
    "query" : { 
    "_id" : NumberLong("928686353793211381") 
    }, 
    "updateobj" : { 

    "$set" : { 
    "ref" : { 
     "$db" : "db2", 
     "$ref" : "coll2", 
     "$id" : NumberLong("928686353793211381") 
     } 
    } 
    }, 
    "nscanned" : 1, 
    "keyUpdates" : 0, 
    "numYield" : 0, 
    "lockStats" : { 
    "timeLockedMicros" : { 
     "r" : NumberLong(0), 
     "w" : NumberLong(200) 
    }, 
    "timeAcquiringMicros" : { 
     "r" : NumberLong(0), 
     "w" : NumberLong(5) 
    } 
    }, 
    "exception" : "not okForStorage", 
    "exceptionCode" : 12527, 
    "millis" : 0, 
    "client" : "10.168.89.9", 
    "user" : "" 
} 

回答

1

按照docs,在DBREF事項字段的順序;所以你需要重新安排你的ref對象爲:

"ref" : { 
    "$ref" : "coll2", 
    "$id" : NumberLong("928686353793211381"), 
    "$db" : "db2" 
} 
+0

好,我知道的感謝! – jackalope

相關問題