Description
type Something struct {
|
Field primitive.Decimal128 `bson:"field,omitempty"` |
}
|
|
|
func main() {
|
// Connect to mongo instance |
// ... |
|
|
something := Something{}
|
collection := client.Database("invoice").Collection("something") |
_, err = collection.InsertOne(context.Background(), something)
|
if err != nil { |
log.Fatal(err)
|
}
|
|
|
}
|
|
After running the above, a record is created with the primitive.Decimal128 field while it should be omitted.
{
|
"field": { |
"$numberDecimal": "0E-6176" |
}
|
}
|