func (self *ResponseBson) MarshalBson(buf *bytes.Buffer) { lenWriter := bson.NewLenWriter(buf) bson.EncodePrefix(buf, bson.Binary, "ServiceMethod") bson.EncodeString(buf, self.ServiceMethod) bson.EncodePrefix(buf, bson.Long, "Seq") bson.EncodeUint64(buf, uint64(self.Seq)) bson.EncodePrefix(buf, bson.Binary, "Error") bson.EncodeString(buf, self.Error) buf.WriteByte(0) lenWriter.RecordLen() }
func MarshalFieldBson(self mysql.Field, buf *bytes.Buffer) { lenWriter := bson.NewLenWriter(buf) bson.EncodePrefix(buf, bson.Binary, "Name") bson.EncodeString(buf, self.Name) bson.EncodePrefix(buf, bson.Long, "Type") bson.EncodeUint64(buf, uint64(self.Type)) buf.WriteByte(0) lenWriter.RecordLen() }
func (self *QueryResult) encodeRowBson(row []interface{}, buf *bytes.Buffer) { lenWriter := bson.NewLenWriter(buf) for i, v := range row { if v == nil { bson.EncodePrefix(buf, bson.Null, bson.Itoa(i)) } else { bson.EncodePrefix(buf, bson.Binary, bson.Itoa(i)) bson.EncodeString(buf, v.(string)) } } buf.WriteByte(0) lenWriter.RecordLen() }
func (self *Query) MarshalBson(buf *bytes.Buffer) { lenWriter := bson.NewLenWriter(buf) bson.EncodePrefix(buf, bson.Binary, "Sql") bson.EncodeString(buf, self.Sql) bson.EncodePrefix(buf, bson.Object, "BindVariables") self.encodeBindVariablesBson(buf) bson.EncodePrefix(buf, bson.Long, "TransactionId") bson.EncodeUint64(buf, uint64(self.TransactionId)) bson.EncodePrefix(buf, bson.Long, "ConnectionId") bson.EncodeUint64(buf, uint64(self.ConnectionId)) bson.EncodePrefix(buf, bson.Long, "SessionId") bson.EncodeUint64(buf, uint64(self.SessionId)) buf.WriteByte(0) lenWriter.RecordLen() }