I am trying to create a floating point column using go-memdb but seems like I am missing enough understanding + documentation to create one. Shouting out for help. In the below example I need "price" to be a decimal number but in the current form is losing its precision. Not sure which indexer to implement.
type Product struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Price float32 `json:"price"`
SKU string `json:"sku"`
CreatedOn string `json:"-"`
UpdatedOn string `json:"-"`
DeletedOn string `json:"-"`
}
schema := &memdb.DBSchema{
Tables: map[string]*memdb.TableSchema{
"product": {
Name: "product",
Indexes: map[string]*memdb.IndexSchema{
"id": {
Name: "id",
Unique: true,
AllowMissing: false,
Indexer: &memdb.StringFieldIndex{Field: "ID"},
},
"name": {
Name: "name",
Indexer: &memdb.StringFieldIndex{Field: "Name"},
},
"description": {
Name: "description",
Indexer: &memdb.StringFieldIndex{Field: "Description"},
},
"price": {
Name: "price",
Indexer: &memdb.StringFieldIndex{Field: "Price"},
},
"sku": {
Name: "sku",
Indexer: &memdb.StringFieldIndex{Field: "SKU"},
},
"createdon": {
Name: "createdon",
Indexer: &memdb.StringFieldIndex{Field: "CreatedOn"},
},
"updatedon": {
Name: "updatedon",
AllowMissing: true,
Indexer: &memdb.StringFieldIndex{Field: "UpdatedOn"},
},
"deletedon": {
Name: "deletedon",
AllowMissing: true,
Indexer: &memdb.StringFieldIndex{Field: "DeletedOn"},
},
},
},
},
}