Exemplo n.º 1
0
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()
}
Exemplo n.º 2
0
func (self *QueryResult) encodeFieldsBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)
	for i, v := range self.Fields {
		bson.EncodePrefix(buf, bson.Object, bson.Itoa(i))
		MarshalFieldBson(v, buf)
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Exemplo n.º 3
0
func (self *QueryResult) encodeRowsBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)
	for i, v := range self.Rows {
		bson.EncodePrefix(buf, bson.Array, bson.Itoa(i))
		self.encodeRowBson(v, buf)
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}