@Chung_Hoang_Van Your decoder makes the default zero. You need to add a case for bsontype.Null. Optionally, you can deal with this after decoding using the bson.RawValue API:
type Product struct {
Id string `json:"id" bson:"_id"`
TotalForSellRawValue bson.RawValue `json:"total_for_sell" bson:"total_for_sell,omitempty"`
}
func (product *Product) TotalForSell() int64 {
switch product.TotalForSellRawValue.Type {
case bson.TypeInt64:
return product.TotalForSellRawValue.Int64()
}
return 0
}