I have a json object sent from a mobile application, looks like this:
{
"product_id": "0123456789",
"name": "PRODUCT_NAME",
"manufacturer": "PRODUCT_MANUFACTURER",
"image_url": "IMAGE_URL",
"additional_info": "",
"store_id": "STORE_ID",
"store_name": "STORE_NAME",
"owner_id": "OWNER_ID",
"quantities": {
"1000": 10.0,
"1500": 12.0,
}
}
The key value in quantities is a for example, can be grams, and the value is a representes a price.
So for example, 1000 grams of rice will cost 10$, and 1500 grams of rice will cost 12.0$ (as a sale or something)
I have a Model Object in my Go code, that has the quantities filed as map[int]float32
I'm trying to find a way to insert this map into a PostgreSQL database I have, but can't figure out how.
This is my Go Model:
type Product struct {
ID string
UUID string
Name string
Manufacturer string
ImageURL string
AdditionalInfo string
StoreID string
StoreName string
OwnerID string
Quantities map[int]float32
}
I read about JSONB but won't it return a json when I retrieve the data? I need it to return a map[int]float32 and not json.