// UnmarshalBson unmarshals QueryResult from buf. func (qr *QueryResult) UnmarshalBson(buf *bytes.Buffer, kind byte) { bson.VerifyObject(kind) bson.Next(buf, 4) kind = bson.NextByte(buf) for kind != bson.EOO { keyName := bson.ReadCString(buf) switch keyName { case "Fields": qr.Fields = mproto.DecodeFieldsBson(buf, kind) case "RowsAffected": qr.RowsAffected = bson.DecodeUint64(buf, kind) case "InsertId": qr.InsertId = bson.DecodeUint64(buf, kind) case "Rows": qr.Rows = mproto.DecodeRowsBson(buf, kind) case "Session": if kind != bson.Null { qr.Session = new(Session) qr.Session.UnmarshalBson(buf, kind) } case "Error": qr.Error = bson.DecodeString(buf, kind) default: bson.Skip(buf, kind) } kind = bson.NextByte(buf) } }
// UnmarshalBson unmarshals QueryResult from buf. func (qr *QueryResult) UnmarshalBson(buf *bytes.Buffer) { bson.Next(buf, 4) kind := bson.NextByte(buf) for kind != bson.EOO { key := bson.ReadCString(buf) switch key { case "Fields": qr.Fields = mproto.DecodeFieldsBson(buf, kind) case "RowsAffected": qr.RowsAffected = bson.DecodeUint64(buf, kind) case "InsertId": qr.InsertId = bson.DecodeUint64(buf, kind) case "Rows": qr.Rows = mproto.DecodeRowsBson(buf, kind) case "Session": qr.Session = new(Session) qr.Session.UnmarshalBson(buf) case "Error": qr.Error = bson.DecodeString(buf, kind) default: panic(bson.NewBsonError("Unrecognized tag %s", key)) } kind = bson.NextByte(buf) } }