0

今天我尝试用$set一​​个 DBRef$db来收集。

但是服务器说:“not okForStorage”,所以操作失败。

附言。我的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" : ""
}
4

1 回答 1

1

根据文档, DBRef 中字段的顺序很重要;所以你需要将你的ref对象重新排序为:

"ref" : {
  "$ref" : "coll2",
  "$id" : NumberLong("928686353793211381"),
  "$db" : "db2"
}
于 2013-01-16T15:07:00.277 回答