Beispiel #1
0
// MarshalBson bson-encodes QueryResult.
func (queryResult *QueryResult) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	// []Field
	{
		bson.EncodePrefix(buf, bson.Array, "Fields")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v1 := range queryResult.Fields {
			_v1.MarshalBson(buf, bson.Itoa(_i))
		}
		lenWriter.Close()
	}
	bson.EncodeUint64(buf, "RowsAffected", queryResult.RowsAffected)
	bson.EncodeUint64(buf, "InsertId", queryResult.InsertId)
	// [][]sqltypes.Value
	{
		bson.EncodePrefix(buf, bson.Array, "Rows")
		lenWriter := bson.NewLenWriter(buf)
		for _i, _v2 := range queryResult.Rows {
			// []sqltypes.Value
			{
				bson.EncodePrefix(buf, bson.Array, bson.Itoa(_i))
				lenWriter := bson.NewLenWriter(buf)
				for _i, _v3 := range _v2 {
					_v3.MarshalBson(buf, bson.Itoa(_i))
				}
				lenWriter.Close()
			}
		}
		lenWriter.Close()
	}

	lenWriter.Close()
}
Beispiel #2
0
func (req *RequestBson) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeString(buf, "ServiceMethod", req.ServiceMethod)
	bson.EncodeUint64(buf, "Seq", req.Seq)

	lenWriter.Close()
}
Beispiel #3
0
// MarshalBson bson-encodes MyType.
func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) {
	bson.EncodeOptionalPrefix(buf, bson.Object, key)
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodeFloat64(buf, "Float64", myType.Float64)
	bson.EncodeString(buf, "String", myType.String)
	bson.EncodeBool(buf, "Bool", myType.Bool)
	bson.EncodeInt64(buf, "Int64", myType.Int64)
	bson.EncodeInt32(buf, "Int32", myType.Int32)
	bson.EncodeInt(buf, "Int", myType.Int)
	bson.EncodeUint64(buf, "Uint64", myType.Uint64)
	bson.EncodeUint32(buf, "Uint32", myType.Uint32)
	bson.EncodeUint(buf, "Uint", myType.Uint)
	bson.EncodeBinary(buf, "Bytes", myType.Bytes)
	bson.EncodeTime(buf, "Time", myType.Time)
	bson.EncodeInterface(buf, "Interface", myType.Interface)

	lenWriter.Close()
}