From 7eadee4e0efa5102abac7f24f002262cf98a0a5f Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:55:25 +0100 Subject: [PATCH 1/6] Added product schema --- internal/database/product/product.go | 411 +++++++++++++++++++++++++++ internal/database/product/queries.go | 2 +- 2 files changed, 412 insertions(+), 1 deletion(-) create mode 100644 internal/database/product/product.go diff --git a/internal/database/product/product.go b/internal/database/product/product.go new file mode 100644 index 0000000..00ce89e --- /dev/null +++ b/internal/database/product/product.go @@ -0,0 +1,411 @@ +package product + +type Product struct { + ID_ string `json:"_id"` + Complete int `json:"complete"` + CategoriesPropertiesTags []string `json:"categories_properties_tags"` + BrandsHierarchy []string `json:"brands_hierarchy"` + Lc string `json:"lc"` + EnvironmentalScoreTags []string `json:"environmental_score_tags"` + NutriscoreVersion string `json:"nutriscore_version"` + LanguagesTags []string `json:"languages_tags"` + Code string `json:"code"` + ServingQuantity float64 `json:"serving_quantity"` + ProductNameDe string `json:"product_name_de"` + ID string `json:"id"` + AllergensHierarchy []interface{} `json:"allergens_hierarchy"` + NutritionGradesTags []string `json:"nutrition_grades_tags"` + TracesFromIngredients string `json:"traces_from_ingredients"` + Traces string `json:"traces"` + BrandsOld string `json:"brands_old"` + NutritionDataPer string `json:"nutrition_data_per"` + NutritionDataPreparedPer string `json:"nutrition_data_prepared_per"` + Nutriscore2023Tags []string `json:"nutriscore_2023_tags"` + ServingSize string `json:"serving_size"` + NutritionScoreBeverage int `json:"nutrition_score_beverage"` + Lang string `json:"lang"` + CountriesTags []string `json:"countries_tags"` + AllergensFromIngredients string `json:"allergens_from_ingredients"` + CreatedT int `json:"created_t"` + NutritionGradeFr string `json:"nutrition_grade_fr"` + NutritionGrades string `json:"nutrition_grades"` + NutritionData string `json:"nutrition_data"` + DataQualityTags []string `json:"data_quality_tags"` + Countries string `json:"countries"` + MiscTags []string `json:"misc_tags"` + CodesTags []string `json:"codes_tags"` + UniqueScansN int `json:"unique_scans_n"` + FoodGroupsTags []interface{} `json:"food_groups_tags"` + States string `json:"states"` + ProductQuantity float64 `json:"product_quantity"` + Brands string `json:"brands"` + Quantity string `json:"quantity"` + EnvironmentalScoreData struct { + Status string `json:"status"` + Missing struct { + Categories int `json:"categories"` + Labels int `json:"labels"` + Ingredients int `json:"ingredients"` + Packagings int `json:"packagings"` + Origins int `json:"origins"` + } `json:"missing"` + MissingAgribalyseMatchWarning int `json:"missing_agribalyse_match_warning"` + Agribalyse struct { + Warning string `json:"warning"` + } `json:"agribalyse"` + MissingKeyData int `json:"missing_key_data"` + Adjustments struct { + OriginsOfIngredients struct { + EpiValue int `json:"epi_value"` + Values struct { + Lb int `json:"lb"` + Es int `json:"es"` + Fr int `json:"fr"` + Lu int `json:"lu"` + De int `json:"de"` + Nl int `json:"nl"` + Is int `json:"is"` + Al int `json:"al"` + Xk int `json:"xk"` + Ro int `json:"ro"` + Ch int `json:"ch"` + Dz int `json:"dz"` + Ps int `json:"ps"` + Mc int `json:"mc"` + Ax int `json:"ax"` + Md int `json:"md"` + Hr int `json:"hr"` + Fi int `json:"fi"` + Dk int `json:"dk"` + Tr int `json:"tr"` + Cz int `json:"cz"` + Cy int `json:"cy"` + No int `json:"no"` + At int `json:"at"` + Fo int `json:"fo"` + Us int `json:"us"` + Tn int `json:"tn"` + Lv int `json:"lv"` + Je int `json:"je"` + Ly int `json:"ly"` + Bg int `json:"bg"` + Sk int `json:"sk"` + World int `json:"world"` + Sm int `json:"sm"` + Gg int `json:"gg"` + Me int `json:"me"` + It int `json:"it"` + Be int `json:"be"` + Rs int `json:"rs"` + Si int `json:"si"` + Im int `json:"im"` + Pl int `json:"pl"` + Gr int `json:"gr"` + Pt int `json:"pt"` + Lt int `json:"lt"` + Mk int `json:"mk"` + Sj int `json:"sj"` + Hu int `json:"hu"` + Li int `json:"li"` + Se int `json:"se"` + Uk int `json:"uk"` + Il int `json:"il"` + Sy int `json:"sy"` + Ma int `json:"ma"` + Ie int `json:"ie"` + Mt int `json:"mt"` + Ba int `json:"ba"` + Eg int `json:"eg"` + Va int `json:"va"` + Gi int `json:"gi"` + Ua int `json:"ua"` + Ee int `json:"ee"` + Ad int `json:"ad"` + } `json:"values"` + TransportationValues struct { + Cy int `json:"cy"` + Tr int `json:"tr"` + Cz int `json:"cz"` + Dk int `json:"dk"` + At int `json:"at"` + No int `json:"no"` + Mc int `json:"mc"` + Ps int `json:"ps"` + Fi int `json:"fi"` + Hr int `json:"hr"` + Md int `json:"md"` + Ax int `json:"ax"` + Us int `json:"us"` + Fo int `json:"fo"` + Tn int `json:"tn"` + Nl int `json:"nl"` + Is int `json:"is"` + Es int `json:"es"` + Lb int `json:"lb"` + Fr int `json:"fr"` + De int `json:"de"` + Lu int `json:"lu"` + Dz int `json:"dz"` + Ch int `json:"ch"` + Xk int `json:"xk"` + Al int `json:"al"` + Ro int `json:"ro"` + Se int `json:"se"` + Uk int `json:"uk"` + Mk int `json:"mk"` + Sj int `json:"sj"` + Hu int `json:"hu"` + Pt int `json:"pt"` + Lt int `json:"lt"` + Li int `json:"li"` + Ee int `json:"ee"` + Ua int `json:"ua"` + Gi int `json:"gi"` + Va int `json:"va"` + Ad int `json:"ad"` + Sy int `json:"sy"` + Il int `json:"il"` + Ba int `json:"ba"` + Eg int `json:"eg"` + Mt int `json:"mt"` + Ie int `json:"ie"` + Ma int `json:"ma"` + Gg int `json:"gg"` + World int `json:"world"` + Sm int `json:"sm"` + Be int `json:"be"` + Rs int `json:"rs"` + It int `json:"it"` + Me int `json:"me"` + Bg int `json:"bg"` + Ly int `json:"ly"` + Je int `json:"je"` + Lv int `json:"lv"` + Sk int `json:"sk"` + Gr int `json:"gr"` + Pl int `json:"pl"` + Im int `json:"im"` + Si int `json:"si"` + } `json:"transportation_values"` + AggregatedOrigins []struct { + Percent int `json:"percent"` + Origin string `json:"origin"` + } `json:"aggregated_origins"` + OriginsFromOriginsField []string `json:"origins_from_origins_field"` + TransportationScores struct { + Ch float64 `json:"ch"` + Dz float64 `json:"dz"` + Ro float64 `json:"ro"` + Xk float64 `json:"xk"` + Al float64 `json:"al"` + Is float64 `json:"is"` + Nl float64 `json:"nl"` + De float64 `json:"de"` + Lu float64 `json:"lu"` + Fr float64 `json:"fr"` + Lb float64 `json:"lb"` + Es float64 `json:"es"` + Tn float64 `json:"tn"` + Us float64 `json:"us"` + Fo float64 `json:"fo"` + At float64 `json:"at"` + No float64 `json:"no"` + Cy float64 `json:"cy"` + Dk float64 `json:"dk"` + Tr float64 `json:"tr"` + Cz float64 `json:"cz"` + Hr float64 `json:"hr"` + Fi float64 `json:"fi"` + Ax float64 `json:"ax"` + Md float64 `json:"md"` + Ps float64 `json:"ps"` + Mc float64 `json:"mc"` + Pl float64 `json:"pl"` + Gr float64 `json:"gr"` + Si float64 `json:"si"` + Im float64 `json:"im"` + Rs float64 `json:"rs"` + Be float64 `json:"be"` + Me float64 `json:"me"` + It float64 `json:"it"` + Sm float64 `json:"sm"` + World float64 `json:"world"` + Gg float64 `json:"gg"` + Sk float64 `json:"sk"` + Lv float64 `json:"lv"` + Je float64 `json:"je"` + Ly float64 `json:"ly"` + Bg float64 `json:"bg"` + Ad float64 `json:"ad"` + Ee float64 `json:"ee"` + Va float64 `json:"va"` + Gi float64 `json:"gi"` + Ua float64 `json:"ua"` + Eg float64 `json:"eg"` + Ba float64 `json:"ba"` + Ie float64 `json:"ie"` + Ma float64 `json:"ma"` + Mt float64 `json:"mt"` + Il float64 `json:"il"` + Sy float64 `json:"sy"` + Uk float64 `json:"uk"` + Se float64 `json:"se"` + Li float64 `json:"li"` + Sj float64 `json:"sj"` + Mk float64 `json:"mk"` + Hu float64 `json:"hu"` + Pt float64 `json:"pt"` + Lt float64 `json:"lt"` + } `json:"transportation_scores"` + Warning string `json:"warning"` + EpiScore int `json:"epi_score"` + OriginsFromCategories []string `json:"origins_from_categories"` + } `json:"origins_of_ingredients"` + ThreatenedSpecies struct { + Warning string `json:"warning"` + } `json:"threatened_species"` + ProductionSystem struct { + Labels []interface{} `json:"labels"` + Value int `json:"value"` + Warning string `json:"warning"` + } `json:"production_system"` + Packaging struct { + Warning string `json:"warning"` + Value int `json:"value"` + } `json:"packaging"` + } `json:"adjustments"` + Grade string `json:"grade"` + } `json:"environmental_score_data"` + UnknownNutrientsTags []interface{} `json:"unknown_nutrients_tags"` + ScansN int `json:"scans_n"` + WeighersTags []interface{} `json:"weighers_tags"` + CategoriesProperties struct { + } `json:"categories_properties"` + BrandsLc string `json:"brands_lc"` + ProductType string `json:"product_type"` + NoNutritionData string `json:"no_nutrition_data"` + Packagings []interface{} `json:"packagings"` + PackagingsMaterials struct { + } `json:"packagings_materials"` + DataSourcesTags []string `json:"data_sources_tags"` + NutriscoreGrade string `json:"nutriscore_grade"` + NovaGroupsTags []string `json:"nova_groups_tags"` + AllergensFromUser string `json:"allergens_from_user"` + LastModifiedT int `json:"last_modified_t"` + CountriesHierarchy []string `json:"countries_hierarchy"` + TracesTags []interface{} `json:"traces_tags"` + Rev int `json:"rev"` + Nutriments struct { + Energy100G int `json:"energy_100g"` + Fat int `json:"fat"` + EnergyKcal int `json:"energy-kcal"` + SugarsValue float64 `json:"sugars_value"` + SugarsUnit string `json:"sugars_unit"` + Carbohydrates float64 `json:"carbohydrates"` + Carbohydrates100G float64 `json:"carbohydrates_100g"` + Energy int `json:"energy"` + SugarsServing float64 `json:"sugars_serving"` + Fat100G int `json:"fat_100g"` + ProteinsValue int `json:"proteins_value"` + EnergyKcalUnit string `json:"energy-kcal_unit"` + CarbohydratesValue float64 `json:"carbohydrates_value"` + Sugars100G float64 `json:"sugars_100g"` + FatUnit string `json:"fat_unit"` + CarbohydratesServing float64 `json:"carbohydrates_serving"` + Proteins int `json:"proteins"` + EnergyValue int `json:"energy_value"` + EnergyUnit string `json:"energy_unit"` + ProteinsUnit string `json:"proteins_unit"` + EnergyKcalValue int `json:"energy-kcal_value"` + EnergyKcal100G int `json:"energy-kcal_100g"` + EnergyKcalServing float64 `json:"energy-kcal_serving"` + FatServing int `json:"fat_serving"` + CarbohydratesUnit string `json:"carbohydrates_unit"` + FatValue int `json:"fat_value"` + Proteins100G int `json:"proteins_100g"` + ProteinsServing int `json:"proteins_serving"` + EnergyKcalValueComputed int `json:"energy-kcal_value_computed"` + EnergyServing int `json:"energy_serving"` + Sugars float64 `json:"sugars"` + } `json:"nutriments"` + ServingQuantityUnit string `json:"serving_quantity_unit"` + CountriesLc string `json:"countries_lc"` + NovaGroupDebug string `json:"nova_group_debug"` + NutriscoreTags []string `json:"nutriscore_tags"` + Nutriscore struct { + Num2021 struct { + Data struct { + Sugars float64 `json:"sugars"` + Energy int `json:"energy"` + IsBeverage int `json:"is_beverage"` + IsWater int `json:"is_water"` + Sodium interface{} `json:"sodium"` + IsCheese int `json:"is_cheese"` + IsFat int `json:"is_fat"` + Proteins int `json:"proteins"` + SaturatedFat int `json:"saturated_fat"` + Fiber int `json:"fiber"` + SaturatedFatRatio int `json:"saturated_fat_ratio"` + FruitsVegetablesNutsColzaWalnutOliveOils int `json:"fruits_vegetables_nuts_colza_walnut_olive_oils"` + } `json:"data"` + Grade string `json:"grade"` + NutriscoreComputed int `json:"nutriscore_computed"` + NutriscoreApplicable int `json:"nutriscore_applicable"` + NutrientsAvailable int `json:"nutrients_available"` + CategoryAvailable int `json:"category_available"` + } `json:"2021"` + Num2023 struct { + NutriscoreComputed int `json:"nutriscore_computed"` + Grade string `json:"grade"` + Data struct { + Proteins int `json:"proteins"` + IsFatOilNutsSeeds int `json:"is_fat_oil_nuts_seeds"` + SaturatedFat int `json:"saturated_fat"` + Fiber interface{} `json:"fiber"` + FruitsVegetablesLegumes interface{} `json:"fruits_vegetables_legumes"` + SaturatedFatRatio int `json:"saturated_fat_ratio"` + Salt interface{} `json:"salt"` + Sugars float64 `json:"sugars"` + IsRedMeatProduct int `json:"is_red_meat_product"` + IsBeverage int `json:"is_beverage"` + Energy int `json:"energy"` + IsWater int `json:"is_water"` + IsCheese int `json:"is_cheese"` + } `json:"data"` + CategoryAvailable int `json:"category_available"` + NutrientsAvailable int `json:"nutrients_available"` + NutriscoreApplicable int `json:"nutriscore_applicable"` + } `json:"2023"` + } `json:"nutriscore"` + Completeness float64 `json:"completeness"` + ProductName string `json:"product_name"` + PackagingMaterialsTags []interface{} `json:"packaging_materials_tags"` + Keywords []string `json:"_keywords"` + LastUpdatedT int `json:"last_updated_t"` + EntryDatesTags []string `json:"entry_dates_tags"` + LanguagesHierarchy []string `json:"languages_hierarchy"` + MainCountriesTags []interface{} `json:"main_countries_tags"` + DataQualityInfoTags []string `json:"data_quality_info_tags"` + Nutriscore2021Tags []string `json:"nutriscore_2021_tags"` + MaxImgid string `json:"max_imgid"` + StatesTags []string `json:"states_tags"` + NutritionScoreWarningNoFruitsVegetablesNuts int `json:"nutrition_score_warning_no_fruits_vegetables_nuts"` + EnvironmentalScoreGrade string `json:"environmental_score_grade"` + PopularityTags []string `json:"popularity_tags"` + PackagingRecyclingTags []interface{} `json:"packaging_recycling_tags"` + CheckersTags []interface{} `json:"checkers_tags"` + NutrientLevels struct { + } `json:"nutrient_levels"` + PnnsGroups1Tags []string `json:"pnns_groups_1_tags"` + LastEditDatesTags []string `json:"last_edit_dates_tags"` + NutritionScoreWarningNoFiber int `json:"nutrition_score_warning_no_fiber"` + InformersTags []string `json:"informers_tags"` + PnnsGroups2 string `json:"pnns_groups_2"` + BrandsTags []string `json:"brands_tags"` + Allergens string `json:"allergens"` + PnnsGroups1 string `json:"pnns_groups_1"` + EcoscoreTags []string `json:"ecoscore_tags"` + PnnsGroups2Tags []string `json:"pnns_groups_2_tags"` + PopularityKey int `json:"popularity_key"` + AllergensTags []interface{} `json:"allergens_tags"` +} diff --git a/internal/database/product/queries.go b/internal/database/product/queries.go index 9620046..06395ad 100644 --- a/internal/database/product/queries.go +++ b/internal/database/product/queries.go @@ -21,7 +21,7 @@ func GetProductByID(db *mongo.Client, id string) (string, error) { return "", fmt.Errorf("failed to find product: %v", err) } - jsonBytes, err := bson.MarshalExtJSON(bsonResult, true, false) + jsonBytes, err := bson.MarshalExtJSON(bsonResult, false, false) if err != nil { return "", fmt.Errorf("failed to marshal product to JSON: %v", err) From 6093c43c290d6aee023281aed2ba11604b5c5549 Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:07:38 +0100 Subject: [PATCH 2/6] Added bson tags to structure --- internal/database/product/product.go | 772 +++++++++++++-------------- 1 file changed, 386 insertions(+), 386 deletions(-) diff --git a/internal/database/product/product.go b/internal/database/product/product.go index 00ce89e..eff1b6d 100644 --- a/internal/database/product/product.go +++ b/internal/database/product/product.go @@ -1,411 +1,411 @@ package product type Product struct { - ID_ string `json:"_id"` - Complete int `json:"complete"` - CategoriesPropertiesTags []string `json:"categories_properties_tags"` - BrandsHierarchy []string `json:"brands_hierarchy"` - Lc string `json:"lc"` - EnvironmentalScoreTags []string `json:"environmental_score_tags"` - NutriscoreVersion string `json:"nutriscore_version"` - LanguagesTags []string `json:"languages_tags"` - Code string `json:"code"` - ServingQuantity float64 `json:"serving_quantity"` - ProductNameDe string `json:"product_name_de"` - ID string `json:"id"` - AllergensHierarchy []interface{} `json:"allergens_hierarchy"` - NutritionGradesTags []string `json:"nutrition_grades_tags"` - TracesFromIngredients string `json:"traces_from_ingredients"` - Traces string `json:"traces"` - BrandsOld string `json:"brands_old"` - NutritionDataPer string `json:"nutrition_data_per"` - NutritionDataPreparedPer string `json:"nutrition_data_prepared_per"` - Nutriscore2023Tags []string `json:"nutriscore_2023_tags"` - ServingSize string `json:"serving_size"` - NutritionScoreBeverage int `json:"nutrition_score_beverage"` - Lang string `json:"lang"` - CountriesTags []string `json:"countries_tags"` - AllergensFromIngredients string `json:"allergens_from_ingredients"` - CreatedT int `json:"created_t"` - NutritionGradeFr string `json:"nutrition_grade_fr"` - NutritionGrades string `json:"nutrition_grades"` - NutritionData string `json:"nutrition_data"` - DataQualityTags []string `json:"data_quality_tags"` - Countries string `json:"countries"` - MiscTags []string `json:"misc_tags"` - CodesTags []string `json:"codes_tags"` - UniqueScansN int `json:"unique_scans_n"` - FoodGroupsTags []interface{} `json:"food_groups_tags"` - States string `json:"states"` - ProductQuantity float64 `json:"product_quantity"` - Brands string `json:"brands"` - Quantity string `json:"quantity"` + ID_ string `json:"_id" bson:"_id"` + Complete int `json:"complete" bson:"complete"` + CategoriesPropertiesTags []string `json:"categories_properties_tags" bson:"categories_properties_tags"` + BrandsHierarchy []string `json:"brands_hierarchy" bson:"brands_hierarchy"` + Lc string `json:"lc" bson:"lc"` + EnvironmentalScoreTags []string `json:"environmental_score_tags" bson:"environmental_score_tags"` + NutriscoreVersion string `json:"nutriscore_version" bson:"nutriscore_version"` + LanguagesTags []string `json:"languages_tags" bson:"languages_tags"` + Code string `json:"code" bson:"code"` + ServingQuantity float64 `json:"serving_quantity" bson:"serving_quantity"` + ProductNameDe string `json:"product_name_de" bson:"product_name_de"` + ID string `json:"id" bson:"id"` + AllergensHierarchy []interface{} `json:"allergens_hierarchy" bson:"allergens_hierarchy"` + NutritionGradesTags []string `json:"nutrition_grades_tags" bson:"nutrition_grades_tags"` + TracesFromIngredients string `json:"traces_from_ingredients" bson:"traces_from_ingredients"` + Traces string `json:"traces" bson:"traces"` + BrandsOld string `json:"brands_old" bson:"brands_old"` + NutritionDataPer string `json:"nutrition_data_per" bson:"nutrition_data_per"` + NutritionDataPreparedPer string `json:"nutrition_data_prepared_per" bson:"nutrition_data_prepared_per"` + Nutriscore2023Tags []string `json:"nutriscore_2023_tags" bson:"nutriscore_2023_tags"` + ServingSize string `json:"serving_size" bson:"serving_size"` + NutritionScoreBeverage int `json:"nutrition_score_beverage" bson:"nutrition_score_beverage"` + Lang string `json:"lang" bson:"lang"` + CountriesTags []string `json:"countries_tags" bson:"countries_tags"` + AllergensFromIngredients string `json:"allergens_from_ingredients" bson:"allergens_from_ingredients"` + CreatedT int `json:"created_t" bson:"created_t"` + NutritionGradeFr string `json:"nutrition_grade_fr" bson:"nutrition_grade_fr"` + NutritionGrades string `json:"nutrition_grades" bson:"nutrition_grades"` + NutritionData string `json:"nutrition_data" bson:"nutrition_data"` + DataQualityTags []string `json:"data_quality_tags" bson:"data_quality_tags"` + Countries string `json:"countries" bson:"countries"` + MiscTags []string `json:"misc_tags" bson:"misc_tags"` + CodesTags []string `json:"codes_tags" bson:"codes_tags"` + UniqueScansN int `json:"unique_scans_n" bson:"unique_scans_n"` + FoodGroupsTags []interface{} `json:"food_groups_tags" bson:"food_groups_tags"` + States string `json:"states" bson:"states"` + ProductQuantity float64 `json:"product_quantity" bson:"product_quantity"` + Brands string `json:"brands" bson:"brands"` + Quantity string `json:"quantity" bson:"quantity"` EnvironmentalScoreData struct { - Status string `json:"status"` + Status string `json:"status" bson:"status"` Missing struct { - Categories int `json:"categories"` - Labels int `json:"labels"` - Ingredients int `json:"ingredients"` - Packagings int `json:"packagings"` - Origins int `json:"origins"` - } `json:"missing"` - MissingAgribalyseMatchWarning int `json:"missing_agribalyse_match_warning"` + Categories int `json:"categories" bson:"categories"` + Labels int `json:"labels" bson:"labels"` + Ingredients int `json:"ingredients" bson:"ingredients"` + Packagings int `json:"packagings" bson:"packagings"` + Origins int `json:"origins" bson:"origins"` + } `json:"missing" bson:"missing"` + MissingAgribalyseMatchWarning int `json:"missing_agribalyse_match_warning" bson:"missing_agribalyse_match_warning"` Agribalyse struct { - Warning string `json:"warning"` - } `json:"agribalyse"` - MissingKeyData int `json:"missing_key_data"` + Warning string `json:"warning" bson:"warning"` + } `json:"agribalyse" bson:"agribalyse"` + MissingKeyData int `json:"missing_key_data" bson:"missing_key_data"` Adjustments struct { OriginsOfIngredients struct { - EpiValue int `json:"epi_value"` + EpiValue int `json:"epi_value" bson:"epi_value"` Values struct { - Lb int `json:"lb"` - Es int `json:"es"` - Fr int `json:"fr"` - Lu int `json:"lu"` - De int `json:"de"` - Nl int `json:"nl"` - Is int `json:"is"` - Al int `json:"al"` - Xk int `json:"xk"` - Ro int `json:"ro"` - Ch int `json:"ch"` - Dz int `json:"dz"` - Ps int `json:"ps"` - Mc int `json:"mc"` - Ax int `json:"ax"` - Md int `json:"md"` - Hr int `json:"hr"` - Fi int `json:"fi"` - Dk int `json:"dk"` - Tr int `json:"tr"` - Cz int `json:"cz"` - Cy int `json:"cy"` - No int `json:"no"` - At int `json:"at"` - Fo int `json:"fo"` - Us int `json:"us"` - Tn int `json:"tn"` - Lv int `json:"lv"` - Je int `json:"je"` - Ly int `json:"ly"` - Bg int `json:"bg"` - Sk int `json:"sk"` - World int `json:"world"` - Sm int `json:"sm"` - Gg int `json:"gg"` - Me int `json:"me"` - It int `json:"it"` - Be int `json:"be"` - Rs int `json:"rs"` - Si int `json:"si"` - Im int `json:"im"` - Pl int `json:"pl"` - Gr int `json:"gr"` - Pt int `json:"pt"` - Lt int `json:"lt"` - Mk int `json:"mk"` - Sj int `json:"sj"` - Hu int `json:"hu"` - Li int `json:"li"` - Se int `json:"se"` - Uk int `json:"uk"` - Il int `json:"il"` - Sy int `json:"sy"` - Ma int `json:"ma"` - Ie int `json:"ie"` - Mt int `json:"mt"` - Ba int `json:"ba"` - Eg int `json:"eg"` - Va int `json:"va"` - Gi int `json:"gi"` - Ua int `json:"ua"` - Ee int `json:"ee"` - Ad int `json:"ad"` - } `json:"values"` + Lb int `json:"lb" bson:"lb"` + Es int `json:"es" bson:"es"` + Fr int `json:"fr" bson:"fr"` + Lu int `json:"lu" bson:"lu"` + De int `json:"de" bson:"de"` + Nl int `json:"nl" bson:"nl"` + Is int `json:"is" bson:"is"` + Al int `json:"al" bson:"al"` + Xk int `json:"xk" bson:"xk"` + Ro int `json:"ro" bson:"ro"` + Ch int `json:"ch" bson:"ch"` + Dz int `json:"dz" bson:"dz"` + Ps int `json:"ps" bson:"ps"` + Mc int `json:"mc" bson:"mc"` + Ax int `json:"ax" bson:"ax"` + Md int `json:"md" bson:"md"` + Hr int `json:"hr" bson:"hr"` + Fi int `json:"fi" bson:"fi"` + Dk int `json:"dk" bson:"dk"` + Tr int `json:"tr" bson:"tr"` + Cz int `json:"cz" bson:"cz"` + Cy int `json:"cy" bson:"cy"` + No int `json:"no" bson:"no"` + At int `json:"at" bson:"at"` + Fo int `json:"fo" bson:"fo"` + Us int `json:"us" bson:"us"` + Tn int `json:"tn" bson:"tn"` + Lv int `json:"lv" bson:"lv"` + Je int `json:"je" bson:"je"` + Ly int `json:"ly" bson:"ly"` + Bg int `json:"bg" bson:"bg"` + Sk int `json:"sk" bson:"sk"` + World int `json:"world" bson:"world"` + Sm int `json:"sm" bson:"sm"` + Gg int `json:"gg" bson:"gg"` + Me int `json:"me" bson:"me"` + It int `json:"it" bson:"it"` + Be int `json:"be" bson:"be"` + Rs int `json:"rs" bson:"rs"` + Si int `json:"si" bson:"si"` + Im int `json:"im" bson:"im"` + Pl int `json:"pl" bson:"pl"` + Gr int `json:"gr" bson:"gr"` + Pt int `json:"pt" bson:"pt"` + Lt int `json:"lt" bson:"lt"` + Mk int `json:"mk" bson:"mk"` + Sj int `json:"sj" bson:"sj"` + Hu int `json:"hu" bson:"hu"` + Li int `json:"li" bson:"li"` + Se int `json:"se" bson:"se"` + Uk int `json:"uk" bson:"uk"` + Il int `json:"il" bson:"il"` + Sy int `json:"sy" bson:"sy"` + Ma int `json:"ma" bson:"ma"` + Ie int `json:"ie" bson:"ie"` + Mt int `json:"mt" bson:"mt"` + Ba int `json:"ba" bson:"ba"` + Eg int `json:"eg" bson:"eg"` + Va int `json:"va" bson:"va"` + Gi int `json:"gi" bson:"gi"` + Ua int `json:"ua" bson:"ua"` + Ee int `json:"ee" bson:"ee"` + Ad int `json:"ad" bson:"ad"` + } `json:"values" bson:"values"` TransportationValues struct { - Cy int `json:"cy"` - Tr int `json:"tr"` - Cz int `json:"cz"` - Dk int `json:"dk"` - At int `json:"at"` - No int `json:"no"` - Mc int `json:"mc"` - Ps int `json:"ps"` - Fi int `json:"fi"` - Hr int `json:"hr"` - Md int `json:"md"` - Ax int `json:"ax"` - Us int `json:"us"` - Fo int `json:"fo"` - Tn int `json:"tn"` - Nl int `json:"nl"` - Is int `json:"is"` - Es int `json:"es"` - Lb int `json:"lb"` - Fr int `json:"fr"` - De int `json:"de"` - Lu int `json:"lu"` - Dz int `json:"dz"` - Ch int `json:"ch"` - Xk int `json:"xk"` - Al int `json:"al"` - Ro int `json:"ro"` - Se int `json:"se"` - Uk int `json:"uk"` - Mk int `json:"mk"` - Sj int `json:"sj"` - Hu int `json:"hu"` - Pt int `json:"pt"` - Lt int `json:"lt"` - Li int `json:"li"` - Ee int `json:"ee"` - Ua int `json:"ua"` - Gi int `json:"gi"` - Va int `json:"va"` - Ad int `json:"ad"` - Sy int `json:"sy"` - Il int `json:"il"` - Ba int `json:"ba"` - Eg int `json:"eg"` - Mt int `json:"mt"` - Ie int `json:"ie"` - Ma int `json:"ma"` - Gg int `json:"gg"` - World int `json:"world"` - Sm int `json:"sm"` - Be int `json:"be"` - Rs int `json:"rs"` - It int `json:"it"` - Me int `json:"me"` - Bg int `json:"bg"` - Ly int `json:"ly"` - Je int `json:"je"` - Lv int `json:"lv"` - Sk int `json:"sk"` - Gr int `json:"gr"` - Pl int `json:"pl"` - Im int `json:"im"` - Si int `json:"si"` - } `json:"transportation_values"` + Cy int `json:"cy" bson:"cy"` + Tr int `json:"tr" bson:"tr"` + Cz int `json:"cz" bson:"cz"` + Dk int `json:"dk" bson:"dk"` + At int `json:"at" bson:"at"` + No int `json:"no" bson:"no"` + Mc int `json:"mc" bson:"mc"` + Ps int `json:"ps" bson:"ps"` + Fi int `json:"fi" bson:"fi"` + Hr int `json:"hr" bson:"hr"` + Md int `json:"md" bson:"md"` + Ax int `json:"ax" bson:"ax"` + Us int `json:"us" bson:"us"` + Fo int `json:"fo" bson:"fo"` + Tn int `json:"tn" bson:"tn"` + Nl int `json:"nl" bson:"nl"` + Is int `json:"is" bson:"is"` + Es int `json:"es" bson:"es"` + Lb int `json:"lb" bson:"lb"` + Fr int `json:"fr" bson:"fr"` + De int `json:"de" bson:"de"` + Lu int `json:"lu" bson:"lu"` + Dz int `json:"dz" bson:"dz"` + Ch int `json:"ch" bson:"ch"` + Xk int `json:"xk" bson:"xk"` + Al int `json:"al" bson:"al"` + Ro int `json:"ro" bson:"ro"` + Se int `json:"se" bson:"se"` + Uk int `json:"uk" bson:"uk"` + Mk int `json:"mk" bson:"mk"` + Sj int `json:"sj" bson:"sj"` + Hu int `json:"hu" bson:"hu"` + Pt int `json:"pt" bson:"pt"` + Lt int `json:"lt" bson:"lt"` + Li int `json:"li" bson:"li"` + Ee int `json:"ee" bson:"ee"` + Ua int `json:"ua" bson:"ua"` + Gi int `json:"gi" bson:"gi"` + Va int `json:"va" bson:"va"` + Ad int `json:"ad" bson:"ad"` + Sy int `json:"sy" bson:"sy"` + Il int `json:"il" bson:"il"` + Ba int `json:"ba" bson:"ba"` + Eg int `json:"eg" bson:"eg"` + Mt int `json:"mt" bson:"mt"` + Ie int `json:"ie" bson:"ie"` + Ma int `json:"ma" bson:"ma"` + Gg int `json:"gg" bson:"gg"` + World int `json:"world" bson:"world"` + Sm int `json:"sm" bson:"sm"` + Be int `json:"be" bson:"be"` + Rs int `json:"rs" bson:"rs"` + It int `json:"it" bson:"it"` + Me int `json:"me" bson:"me"` + Bg int `json:"bg" bson:"bg"` + Ly int `json:"ly" bson:"ly"` + Je int `json:"je" bson:"je"` + Lv int `json:"lv" bson:"lv"` + Sk int `json:"sk" bson:"sk"` + Gr int `json:"gr" bson:"gr"` + Pl int `json:"pl" bson:"pl"` + Im int `json:"im" bson:"im"` + Si int `json:"si" bson:"si"` + } `json:"transportation_values" bson:"transportation_values"` AggregatedOrigins []struct { - Percent int `json:"percent"` - Origin string `json:"origin"` - } `json:"aggregated_origins"` - OriginsFromOriginsField []string `json:"origins_from_origins_field"` + Percent int `json:"percent" bson:"percent"` + Origin string `json:"origin" bson:"origin"` + } `json:"aggregated_origins" bson:"aggregated_origins"` + OriginsFromOriginsField []string `json:"origins_from_origins_field" bson:"origins_from_origins_field"` TransportationScores struct { - Ch float64 `json:"ch"` - Dz float64 `json:"dz"` - Ro float64 `json:"ro"` - Xk float64 `json:"xk"` - Al float64 `json:"al"` - Is float64 `json:"is"` - Nl float64 `json:"nl"` - De float64 `json:"de"` - Lu float64 `json:"lu"` - Fr float64 `json:"fr"` - Lb float64 `json:"lb"` - Es float64 `json:"es"` - Tn float64 `json:"tn"` - Us float64 `json:"us"` - Fo float64 `json:"fo"` - At float64 `json:"at"` - No float64 `json:"no"` - Cy float64 `json:"cy"` - Dk float64 `json:"dk"` - Tr float64 `json:"tr"` - Cz float64 `json:"cz"` - Hr float64 `json:"hr"` - Fi float64 `json:"fi"` - Ax float64 `json:"ax"` - Md float64 `json:"md"` - Ps float64 `json:"ps"` - Mc float64 `json:"mc"` - Pl float64 `json:"pl"` - Gr float64 `json:"gr"` - Si float64 `json:"si"` - Im float64 `json:"im"` - Rs float64 `json:"rs"` - Be float64 `json:"be"` - Me float64 `json:"me"` - It float64 `json:"it"` - Sm float64 `json:"sm"` - World float64 `json:"world"` - Gg float64 `json:"gg"` - Sk float64 `json:"sk"` - Lv float64 `json:"lv"` - Je float64 `json:"je"` - Ly float64 `json:"ly"` - Bg float64 `json:"bg"` - Ad float64 `json:"ad"` - Ee float64 `json:"ee"` - Va float64 `json:"va"` - Gi float64 `json:"gi"` - Ua float64 `json:"ua"` - Eg float64 `json:"eg"` - Ba float64 `json:"ba"` - Ie float64 `json:"ie"` - Ma float64 `json:"ma"` - Mt float64 `json:"mt"` - Il float64 `json:"il"` - Sy float64 `json:"sy"` - Uk float64 `json:"uk"` - Se float64 `json:"se"` - Li float64 `json:"li"` - Sj float64 `json:"sj"` - Mk float64 `json:"mk"` - Hu float64 `json:"hu"` - Pt float64 `json:"pt"` - Lt float64 `json:"lt"` - } `json:"transportation_scores"` - Warning string `json:"warning"` - EpiScore int `json:"epi_score"` - OriginsFromCategories []string `json:"origins_from_categories"` - } `json:"origins_of_ingredients"` + Ch float64 `json:"ch" bson:"ch"` + Dz float64 `json:"dz" bson:"dz"` + Ro float64 `json:"ro" bson:"ro"` + Xk float64 `json:"xk" bson:"xk"` + Al float64 `json:"al" bson:"al"` + Is float64 `json:"is" bson:"is"` + Nl float64 `json:"nl" bson:"nl"` + De float64 `json:"de" bson:"de"` + Lu float64 `json:"lu" bson:"lu"` + Fr float64 `json:"fr" bson:"fr"` + Lb float64 `json:"lb" bson:"lb"` + Es float64 `json:"es" bson:"es"` + Tn float64 `json:"tn" bson:"tn"` + Us float64 `json:"us" bson:"us"` + Fo float64 `json:"fo" bson:"fo"` + At float64 `json:"at" bson:"at"` + No float64 `json:"no" bson:"no"` + Cy float64 `json:"cy" bson:"cy"` + Dk float64 `json:"dk" bson:"dk"` + Tr float64 `json:"tr" bson:"tr"` + Cz float64 `json:"cz" bson:"cz"` + Hr float64 `json:"hr" bson:"hr"` + Fi float64 `json:"fi" bson:"fi"` + Ax float64 `json:"ax" bson:"ax"` + Md float64 `json:"md" bson:"md"` + Ps float64 `json:"ps" bson:"ps"` + Mc float64 `json:"mc" bson:"mc"` + Pl float64 `json:"pl" bson:"pl"` + Gr float64 `json:"gr" bson:"gr"` + Si float64 `json:"si" bson:"si"` + Im float64 `json:"im" bson:"im"` + Rs float64 `json:"rs" bson:"rs"` + Be float64 `json:"be" bson:"be"` + Me float64 `json:"me" bson:"me"` + It float64 `json:"it" bson:"it"` + Sm float64 `json:"sm" bson:"sm"` + World float64 `json:"world" bson:"world"` + Gg float64 `json:"gg" bson:"gg"` + Sk float64 `json:"sk" bson:"sk"` + Lv float64 `json:"lv" bson:"lv"` + Je float64 `json:"je" bson:"je"` + Ly float64 `json:"ly" bson:"ly"` + Bg float64 `json:"bg" bson:"bg"` + Ad float64 `json:"ad" bson:"ad"` + Ee float64 `json:"ee" bson:"ee"` + Va float64 `json:"va" bson:"va"` + Gi float64 `json:"gi" bson:"gi"` + Ua float64 `json:"ua" bson:"ua"` + Eg float64 `json:"eg" bson:"eg"` + Ba float64 `json:"ba" bson:"ba"` + Ie float64 `json:"ie" bson:"ie"` + Ma float64 `json:"ma" bson:"ma"` + Mt float64 `json:"mt" bson:"mt"` + Il float64 `json:"il" bson:"il"` + Sy float64 `json:"sy" bson:"sy"` + Uk float64 `json:"uk" bson:"uk"` + Se float64 `json:"se" bson:"se"` + Li float64 `json:"li" bson:"li"` + Sj float64 `json:"sj" bson:"sj"` + Mk float64 `json:"mk" bson:"mk"` + Hu float64 `json:"hu" bson:"hu"` + Pt float64 `json:"pt" bson:"pt"` + Lt float64 `json:"lt" bson:"lt"` + } `json:"transportation_scores" bson:"transportation_scores"` + Warning string `json:"warning" bson:"warning"` + EpiScore int `json:"epi_score" bson:"epi_score"` + OriginsFromCategories []string `json:"origins_from_categories" bson:"origins_from_categories"` + } `json:"origins_of_ingredients" bson:"origins_of_ingredients"` ThreatenedSpecies struct { - Warning string `json:"warning"` - } `json:"threatened_species"` + Warning string `json:"warning" bson:"warning"` + } `json:"threatened_species" bson:"threatened_species"` ProductionSystem struct { - Labels []interface{} `json:"labels"` - Value int `json:"value"` - Warning string `json:"warning"` - } `json:"production_system"` + Labels []interface{} `json:"labels" bson:"labels"` + Value int `json:"value" bson:"value"` + Warning string `json:"warning" bson:"warning"` + } `json:"production_system" bson:"production_system"` Packaging struct { - Warning string `json:"warning"` - Value int `json:"value"` - } `json:"packaging"` - } `json:"adjustments"` - Grade string `json:"grade"` - } `json:"environmental_score_data"` - UnknownNutrientsTags []interface{} `json:"unknown_nutrients_tags"` - ScansN int `json:"scans_n"` - WeighersTags []interface{} `json:"weighers_tags"` + Warning string `json:"warning" bson:"warning"` + Value int `json:"value" bson:"value"` + } `json:"packaging" bson:"packaging"` + } `json:"adjustments" bson:"adjustments"` + Grade string `json:"grade" bson:"grade"` + } `json:"environmental_score_data" bson:"environmental_score_data"` + UnknownNutrientsTags []interface{} `json:"unknown_nutrients_tags" bson:"unknown_nutrients_tags"` + ScansN int `json:"scans_n" bson:"scans_n"` + WeighersTags []interface{} `json:"weighers_tags" bson:"weighers_tags"` CategoriesProperties struct { - } `json:"categories_properties"` - BrandsLc string `json:"brands_lc"` - ProductType string `json:"product_type"` - NoNutritionData string `json:"no_nutrition_data"` - Packagings []interface{} `json:"packagings"` + } `json:"categories_properties" bson:"categories_properties"` + BrandsLc string `json:"brands_lc" bson:"brands_lc"` + ProductType string `json:"product_type" bson:"product_type"` + NoNutritionData string `json:"no_nutrition_data" bson:"no_nutrition_data"` + Packagings []interface{} `json:"packagings" bson:"packagings"` PackagingsMaterials struct { - } `json:"packagings_materials"` - DataSourcesTags []string `json:"data_sources_tags"` - NutriscoreGrade string `json:"nutriscore_grade"` - NovaGroupsTags []string `json:"nova_groups_tags"` - AllergensFromUser string `json:"allergens_from_user"` - LastModifiedT int `json:"last_modified_t"` - CountriesHierarchy []string `json:"countries_hierarchy"` - TracesTags []interface{} `json:"traces_tags"` - Rev int `json:"rev"` + } `json:"packagings_materials" bson:"packagings_materials"` + DataSourcesTags []string `json:"data_sources_tags" bson:"data_sources_tags"` + NutriscoreGrade string `json:"nutriscore_grade" bson:"nutriscore_grade"` + NovaGroupsTags []string `json:"nova_groups_tags" bson:"nova_groups_tags"` + AllergensFromUser string `json:"allergens_from_user" bson:"allergens_from_user"` + LastModifiedT int `json:"last_modified_t" bson:"last_modified_t"` + CountriesHierarchy []string `json:"countries_hierarchy" bson:"countries_hierarchy"` + TracesTags []interface{} `json:"traces_tags" bson:"traces_tags"` + Rev int `json:"rev" bson:"rev"` Nutriments struct { - Energy100G int `json:"energy_100g"` - Fat int `json:"fat"` - EnergyKcal int `json:"energy-kcal"` - SugarsValue float64 `json:"sugars_value"` - SugarsUnit string `json:"sugars_unit"` - Carbohydrates float64 `json:"carbohydrates"` - Carbohydrates100G float64 `json:"carbohydrates_100g"` - Energy int `json:"energy"` - SugarsServing float64 `json:"sugars_serving"` - Fat100G int `json:"fat_100g"` - ProteinsValue int `json:"proteins_value"` - EnergyKcalUnit string `json:"energy-kcal_unit"` - CarbohydratesValue float64 `json:"carbohydrates_value"` - Sugars100G float64 `json:"sugars_100g"` - FatUnit string `json:"fat_unit"` - CarbohydratesServing float64 `json:"carbohydrates_serving"` - Proteins int `json:"proteins"` - EnergyValue int `json:"energy_value"` - EnergyUnit string `json:"energy_unit"` - ProteinsUnit string `json:"proteins_unit"` - EnergyKcalValue int `json:"energy-kcal_value"` - EnergyKcal100G int `json:"energy-kcal_100g"` - EnergyKcalServing float64 `json:"energy-kcal_serving"` - FatServing int `json:"fat_serving"` - CarbohydratesUnit string `json:"carbohydrates_unit"` - FatValue int `json:"fat_value"` - Proteins100G int `json:"proteins_100g"` - ProteinsServing int `json:"proteins_serving"` - EnergyKcalValueComputed int `json:"energy-kcal_value_computed"` - EnergyServing int `json:"energy_serving"` - Sugars float64 `json:"sugars"` - } `json:"nutriments"` - ServingQuantityUnit string `json:"serving_quantity_unit"` - CountriesLc string `json:"countries_lc"` - NovaGroupDebug string `json:"nova_group_debug"` - NutriscoreTags []string `json:"nutriscore_tags"` + Energy100G int `json:"energy_100g" bson:"energy_100g"` + Fat int `json:"fat" bson:"fat"` + EnergyKcal int `json:"energy-kcal" bson:"energy-kcal"` + SugarsValue float64 `json:"sugars_value" bson:"sugars_value"` + SugarsUnit string `json:"sugars_unit" bson:"sugars_unit"` + Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates"` + Carbohydrates100G float64 `json:"carbohydrates_100g" bson:"carbohydrates_100g"` + Energy int `json:"energy" bson:"energy"` + SugarsServing float64 `json:"sugars_serving" bson:"sugars_serving"` + Fat100G int `json:"fat_100g" bson:"fat_100g"` + ProteinsValue int `json:"proteins_value" bson:"proteins_value"` + EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"` + CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value"` + Sugars100G float64 `json:"sugars_100g" bson:"sugars_100g"` + FatUnit string `json:"fat_unit" bson:"fat_unit"` + CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving"` + Proteins int `json:"proteins" bson:"proteins"` + EnergyValue int `json:"energy_value" bson:"energy_value"` + EnergyUnit string `json:"energy_unit" bson:"energy_unit"` + ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"` + EnergyKcalValue int `json:"energy-kcal_value" bson:"energy-kcal_value"` + EnergyKcal100G int `json:"energy-kcal_100g" bson:"energy-kcal_100g"` + EnergyKcalServing float64 `json:"energy-kcal_serving" bson:"energy-kcal_serving"` + FatServing int `json:"fat_serving" bson:"fat_serving"` + CarbohydratesUnit string `json:"carbohydrates_unit" bson:"carbohydrates_unit"` + FatValue int `json:"fat_value" bson:"fat_value"` + Proteins100G int `json:"proteins_100g" bson:"proteins_100g"` + ProteinsServing int `json:"proteins_serving" bson:"proteins_serving"` + EnergyKcalValueComputed int `json:"energy-kcal_value_computed" bson:"energy-kcal_value_computed"` + EnergyServing int `json:"energy_serving" bson:"energy_serving"` + Sugars float64 `json:"sugars" bson:"sugars"` + } `json:"nutriments" bson:"nutriments"` + ServingQuantityUnit string `json:"serving_quantity_unit" bson:"serving_quantity_unit"` + CountriesLc string `json:"countries_lc" bson:"countries_lc"` + NovaGroupDebug string `json:"nova_group_debug" bson:"nova_group_debug"` + NutriscoreTags []string `json:"nutriscore_tags" bson:"nutriscore_tags"` Nutriscore struct { Num2021 struct { Data struct { - Sugars float64 `json:"sugars"` - Energy int `json:"energy"` - IsBeverage int `json:"is_beverage"` - IsWater int `json:"is_water"` - Sodium interface{} `json:"sodium"` - IsCheese int `json:"is_cheese"` - IsFat int `json:"is_fat"` - Proteins int `json:"proteins"` - SaturatedFat int `json:"saturated_fat"` - Fiber int `json:"fiber"` - SaturatedFatRatio int `json:"saturated_fat_ratio"` - FruitsVegetablesNutsColzaWalnutOliveOils int `json:"fruits_vegetables_nuts_colza_walnut_olive_oils"` - } `json:"data"` - Grade string `json:"grade"` - NutriscoreComputed int `json:"nutriscore_computed"` - NutriscoreApplicable int `json:"nutriscore_applicable"` - NutrientsAvailable int `json:"nutrients_available"` - CategoryAvailable int `json:"category_available"` - } `json:"2021"` + Sugars float64 `json:"sugars" bson:"sugars"` + Energy int `json:"energy" bson:"energy"` + IsBeverage int `json:"is_beverage" bson:"is_beverage"` + IsWater int `json:"is_water" bson:"is_water"` + Sodium interface{} `json:"sodium" bson:"sodium"` + IsCheese int `json:"is_cheese" bson:"is_cheese"` + IsFat int `json:"is_fat" bson:"is_fat"` + Proteins int `json:"proteins" bson:"proteins"` + SaturatedFat int `json:"saturated_fat" bson:"saturated_fat"` + Fiber int `json:"fiber" bson:"fiber"` + SaturatedFatRatio int `json:"saturated_fat_ratio" bson:"saturated_fat_ratio"` + FruitsVegetablesNutsColzaWalnutOliveOils int `json:"fruits_vegetables_nuts_colza_walnut_olive_oils" bson:"fruits_vegetables_nuts_colza_walnut_olive_oils"` + } `json:"data" bson:"data"` + Grade string `json:"grade" bson:"grade"` + NutriscoreComputed int `json:"nutriscore_computed" bson:"nutriscore_computed"` + NutriscoreApplicable int `json:"nutriscore_applicable" bson:"nutriscore_applicable"` + NutrientsAvailable int `json:"nutrients_available" bson:"nutrients_available"` + CategoryAvailable int `json:"category_available" bson:"category_available"` + } `json:"2021" bson:"2021"` Num2023 struct { - NutriscoreComputed int `json:"nutriscore_computed"` - Grade string `json:"grade"` + NutriscoreComputed int `json:"nutriscore_computed" bson:"nutriscore_computed"` + Grade string `json:"grade" bson:"grade"` Data struct { - Proteins int `json:"proteins"` - IsFatOilNutsSeeds int `json:"is_fat_oil_nuts_seeds"` - SaturatedFat int `json:"saturated_fat"` - Fiber interface{} `json:"fiber"` - FruitsVegetablesLegumes interface{} `json:"fruits_vegetables_legumes"` - SaturatedFatRatio int `json:"saturated_fat_ratio"` - Salt interface{} `json:"salt"` - Sugars float64 `json:"sugars"` - IsRedMeatProduct int `json:"is_red_meat_product"` - IsBeverage int `json:"is_beverage"` - Energy int `json:"energy"` - IsWater int `json:"is_water"` - IsCheese int `json:"is_cheese"` - } `json:"data"` - CategoryAvailable int `json:"category_available"` - NutrientsAvailable int `json:"nutrients_available"` - NutriscoreApplicable int `json:"nutriscore_applicable"` - } `json:"2023"` - } `json:"nutriscore"` - Completeness float64 `json:"completeness"` - ProductName string `json:"product_name"` - PackagingMaterialsTags []interface{} `json:"packaging_materials_tags"` - Keywords []string `json:"_keywords"` - LastUpdatedT int `json:"last_updated_t"` - EntryDatesTags []string `json:"entry_dates_tags"` - LanguagesHierarchy []string `json:"languages_hierarchy"` - MainCountriesTags []interface{} `json:"main_countries_tags"` - DataQualityInfoTags []string `json:"data_quality_info_tags"` - Nutriscore2021Tags []string `json:"nutriscore_2021_tags"` - MaxImgid string `json:"max_imgid"` - StatesTags []string `json:"states_tags"` - NutritionScoreWarningNoFruitsVegetablesNuts int `json:"nutrition_score_warning_no_fruits_vegetables_nuts"` - EnvironmentalScoreGrade string `json:"environmental_score_grade"` - PopularityTags []string `json:"popularity_tags"` - PackagingRecyclingTags []interface{} `json:"packaging_recycling_tags"` - CheckersTags []interface{} `json:"checkers_tags"` + Proteins int `json:"proteins" bson:"proteins"` + IsFatOilNutsSeeds int `json:"is_fat_oil_nuts_seeds" bson:"is_fat_oil_nuts_seeds"` + SaturatedFat int `json:"saturated_fat" bson:"saturated_fat"` + Fiber interface{} `json:"fiber" bson:"fiber"` + FruitsVegetablesLegumes interface{} `json:"fruits_vegetables_legumes" bson:"fruits_vegetables_legumes"` + SaturatedFatRatio int `json:"saturated_fat_ratio" bson:"saturated_fat_ratio"` + Salt interface{} `json:"salt" bson:"salt"` + Sugars float64 `json:"sugars" bson:"sugars"` + IsRedMeatProduct int `json:"is_red_meat_product" bson:"is_red_meat_product"` + IsBeverage int `json:"is_beverage" bson:"is_beverage"` + Energy int `json:"energy" bson:"energy"` + IsWater int `json:"is_water" bson:"is_water"` + IsCheese int `json:"is_cheese" bson:"is_cheese"` + } `json:"data" bson:"data"` + CategoryAvailable int `json:"category_available" bson:"category_available"` + NutrientsAvailable int `json:"nutrients_available" bson:"nutrients_available"` + NutriscoreApplicable int `json:"nutriscore_applicable" bson:"nutriscore_applicable"` + } `json:"2023" bson:"2023"` + } `json:"nutriscore" bson:"nutriscore"` + Completeness float64 `json:"completeness" bson:"completeness"` + ProductName string `json:"product_name" bson:"product_name"` + PackagingMaterialsTags []interface{} `json:"packaging_materials_tags" bson:"packaging_materials_tags"` + Keywords []string `json:"_keywords" bson:"_keywords"` + LastUpdatedT int `json:"last_updated_t" bson:"last_updated_t"` + EntryDatesTags []string `json:"entry_dates_tags" bson:"entry_dates_tags"` + LanguagesHierarchy []string `json:"languages_hierarchy" bson:"languages_hierarchy"` + MainCountriesTags []interface{} `json:"main_countries_tags" bson:"main_countries_tags"` + DataQualityInfoTags []string `json:"data_quality_info_tags" bson:"data_quality_info_tags"` + Nutriscore2021Tags []string `json:"nutriscore_2021_tags" bson:"nutriscore_2021_tags"` + MaxImgid string `json:"max_imgid" bson:"max_imgid"` + StatesTags []string `json:"states_tags" bson:"states_tags"` + NutritionScoreWarningNoFruitsVegetablesNuts int `json:"nutrition_score_warning_no_fruits_vegetables_nuts" bson:"nutrition_score_warning_no_fruits_vegetables_nuts"` + EnvironmentalScoreGrade string `json:"environmental_score_grade" bson:"environmental_score_grade"` + PopularityTags []string `json:"popularity_tags" bson:"popularity_tags"` + PackagingRecyclingTags []interface{} `json:"packaging_recycling_tags" bson:"packaging_recycling_tags"` + CheckersTags []interface{} `json:"checkers_tags" bson:"checkers_tags"` NutrientLevels struct { - } `json:"nutrient_levels"` - PnnsGroups1Tags []string `json:"pnns_groups_1_tags"` - LastEditDatesTags []string `json:"last_edit_dates_tags"` - NutritionScoreWarningNoFiber int `json:"nutrition_score_warning_no_fiber"` - InformersTags []string `json:"informers_tags"` - PnnsGroups2 string `json:"pnns_groups_2"` - BrandsTags []string `json:"brands_tags"` - Allergens string `json:"allergens"` - PnnsGroups1 string `json:"pnns_groups_1"` - EcoscoreTags []string `json:"ecoscore_tags"` - PnnsGroups2Tags []string `json:"pnns_groups_2_tags"` - PopularityKey int `json:"popularity_key"` - AllergensTags []interface{} `json:"allergens_tags"` + } `json:"nutrient_levels" bson:"nutrient_levels"` + PnnsGroups1Tags []string `json:"pnns_groups_1_tags" bson:"pnns_groups_1_tags"` + LastEditDatesTags []string `json:"last_edit_dates_tags" bson:"last_edit_dates_tags"` + NutritionScoreWarningNoFiber int `json:"nutrition_score_warning_no_fiber" bson:"nutrition_score_warning_no_fiber"` + InformersTags []string `json:"informers_tags" bson:"informers_tags"` + PnnsGroups2 string `json:"pnns_groups_2" bson:"pnns_groups_2"` + BrandsTags []string `json:"brands_tags" bson:"brands_tags"` + Allergens string `json:"allergens" bson:"allergens"` + PnnsGroups1 string `json:"pnns_groups_1" bson:"pnns_groups_1"` + EcoscoreTags []string `json:"ecoscore_tags" bson:"ecoscore_tags"` + PnnsGroups2Tags []string `json:"pnns_groups_2_tags" bson:"pnns_groups_2_tags"` + PopularityKey int `json:"popularity_key" bson:"popularity_key"` + AllergensTags []interface{} `json:"allergens_tags" bson:"allergens_tags"` } From 24ef4a8dc20e3f36d28fdcd5a7fb46bd85605b41 Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:07:52 +0100 Subject: [PATCH 3/6] Made product endpoint return proper json object --- internal/database/product/queries.go | 17 ++++++----------- internal/handlers/product/getId.go | 6 +++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/internal/database/product/queries.go b/internal/database/product/queries.go index 06395ad..a2eb2af 100644 --- a/internal/database/product/queries.go +++ b/internal/database/product/queries.go @@ -10,24 +10,19 @@ import ( "go.mongodb.org/mongo-driver/v2/mongo/options" ) -func GetProductByID(db *mongo.Client, id string) (string, error) { - bsonResult, err := db.Database("off").Collection("products").FindOne(context.TODO(), bson.M{"_id": id}).Raw() +func GetProductByID(db *mongo.Client, id string) (*Product, error) { + var product *Product = new(Product) + err := db.Database("off").Collection("products").FindOne(context.TODO(), bson.M{"_id": id}).Decode(product) if err == mongo.ErrNoDocuments { - return "", nil + return nil, nil } if err != nil { - return "", fmt.Errorf("failed to find product: %v", err) + return nil, fmt.Errorf("failed to find product: %v", err) } - jsonBytes, err := bson.MarshalExtJSON(bsonResult, false, false) - - if err != nil { - return "", fmt.Errorf("failed to marshal product to JSON: %v", err) - } - - return string(jsonBytes), nil + return product, nil } func SearchProductByName(db *mongo.Client, query string, limit int) (string, error) { diff --git a/internal/handlers/product/getId.go b/internal/handlers/product/getId.go index 392822b..f8cdca3 100644 --- a/internal/handlers/product/getId.go +++ b/internal/handlers/product/getId.go @@ -15,17 +15,17 @@ func (p *ProductController) GetID(c *gin.Context) { return } - productJSON, err := product.GetProductByID(p.DB, id) + product, err := product.GetProductByID(p.DB, id) if err != nil { log.Println(err) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - if productJSON == "" { + if product == nil { c.JSON(http.StatusNotFound, gin.H{"error": "Product not found"}) return } - c.JSON(http.StatusOK, gin.H{"product": productJSON}) + c.JSON(http.StatusOK, gin.H{"product": product}) } From 970aa83bd3b25a65dfc12582cc54085da888ec08 Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:36:20 +0100 Subject: [PATCH 4/6] Allow truncating of types to smaller types --- internal/database/product/product.go | 570 +++++++++++++-------------- 1 file changed, 285 insertions(+), 285 deletions(-) diff --git a/internal/database/product/product.go b/internal/database/product/product.go index eff1b6d..8d49da3 100644 --- a/internal/database/product/product.go +++ b/internal/database/product/product.go @@ -2,7 +2,7 @@ package product type Product struct { ID_ string `json:"_id" bson:"_id"` - Complete int `json:"complete" bson:"complete"` + Complete int `json:"complete" bson:"complete,truncate"` CategoriesPropertiesTags []string `json:"categories_properties_tags" bson:"categories_properties_tags"` BrandsHierarchy []string `json:"brands_hierarchy" bson:"brands_hierarchy"` Lc string `json:"lc" bson:"lc"` @@ -10,10 +10,10 @@ type Product struct { NutriscoreVersion string `json:"nutriscore_version" bson:"nutriscore_version"` LanguagesTags []string `json:"languages_tags" bson:"languages_tags"` Code string `json:"code" bson:"code"` - ServingQuantity float64 `json:"serving_quantity" bson:"serving_quantity"` + ServingQuantity float64 `json:"serving_quantity" bson:"serving_quantity,truncate"` ProductNameDe string `json:"product_name_de" bson:"product_name_de"` ID string `json:"id" bson:"id"` - AllergensHierarchy []interface{} `json:"allergens_hierarchy" bson:"allergens_hierarchy"` + AllergensHierarchy []interface{} `json:"allergens_hierarchy" bson:"allergens_hierarchy,truncate"` NutritionGradesTags []string `json:"nutrition_grades_tags" bson:"nutrition_grades_tags"` TracesFromIngredients string `json:"traces_from_ingredients" bson:"traces_from_ingredients"` Traces string `json:"traces" bson:"traces"` @@ -22,11 +22,11 @@ type Product struct { NutritionDataPreparedPer string `json:"nutrition_data_prepared_per" bson:"nutrition_data_prepared_per"` Nutriscore2023Tags []string `json:"nutriscore_2023_tags" bson:"nutriscore_2023_tags"` ServingSize string `json:"serving_size" bson:"serving_size"` - NutritionScoreBeverage int `json:"nutrition_score_beverage" bson:"nutrition_score_beverage"` + NutritionScoreBeverage int `json:"nutrition_score_beverage" bson:"nutrition_score_beverage,truncate"` Lang string `json:"lang" bson:"lang"` CountriesTags []string `json:"countries_tags" bson:"countries_tags"` AllergensFromIngredients string `json:"allergens_from_ingredients" bson:"allergens_from_ingredients"` - CreatedT int `json:"created_t" bson:"created_t"` + CreatedT int `json:"created_t" bson:"created_t,truncate"` NutritionGradeFr string `json:"nutrition_grade_fr" bson:"nutrition_grade_fr"` NutritionGrades string `json:"nutrition_grades" bson:"nutrition_grades"` NutritionData string `json:"nutrition_data" bson:"nutrition_data"` @@ -34,299 +34,299 @@ type Product struct { Countries string `json:"countries" bson:"countries"` MiscTags []string `json:"misc_tags" bson:"misc_tags"` CodesTags []string `json:"codes_tags" bson:"codes_tags"` - UniqueScansN int `json:"unique_scans_n" bson:"unique_scans_n"` - FoodGroupsTags []interface{} `json:"food_groups_tags" bson:"food_groups_tags"` + UniqueScansN int `json:"unique_scans_n" bson:"unique_scans_n,truncate"` + FoodGroupsTags []interface{} `json:"food_groups_tags" bson:"food_groups_tags,truncate"` States string `json:"states" bson:"states"` - ProductQuantity float64 `json:"product_quantity" bson:"product_quantity"` + ProductQuantity float64 `json:"product_quantity" bson:"product_quantity,truncate"` Brands string `json:"brands" bson:"brands"` Quantity string `json:"quantity" bson:"quantity"` EnvironmentalScoreData struct { Status string `json:"status" bson:"status"` Missing struct { - Categories int `json:"categories" bson:"categories"` - Labels int `json:"labels" bson:"labels"` - Ingredients int `json:"ingredients" bson:"ingredients"` - Packagings int `json:"packagings" bson:"packagings"` - Origins int `json:"origins" bson:"origins"` + Categories int `json:"categories" bson:"categories,truncate"` + Labels int `json:"labels" bson:"labels,truncate"` + Ingredients int `json:"ingredients" bson:"ingredients,truncate"` + Packagings int `json:"packagings" bson:"packagings,truncate"` + Origins int `json:"origins" bson:"origins,truncate"` } `json:"missing" bson:"missing"` - MissingAgribalyseMatchWarning int `json:"missing_agribalyse_match_warning" bson:"missing_agribalyse_match_warning"` + MissingAgribalyseMatchWarning int `json:"missing_agribalyse_match_warning" bson:"missing_agribalyse_match_warning,truncate"` Agribalyse struct { Warning string `json:"warning" bson:"warning"` } `json:"agribalyse" bson:"agribalyse"` - MissingKeyData int `json:"missing_key_data" bson:"missing_key_data"` + MissingKeyData int `json:"missing_key_data" bson:"missing_key_data,truncate"` Adjustments struct { OriginsOfIngredients struct { - EpiValue int `json:"epi_value" bson:"epi_value"` + EpiValue int `json:"epi_value" bson:"epi_value,truncate"` Values struct { - Lb int `json:"lb" bson:"lb"` - Es int `json:"es" bson:"es"` - Fr int `json:"fr" bson:"fr"` - Lu int `json:"lu" bson:"lu"` - De int `json:"de" bson:"de"` - Nl int `json:"nl" bson:"nl"` - Is int `json:"is" bson:"is"` - Al int `json:"al" bson:"al"` - Xk int `json:"xk" bson:"xk"` - Ro int `json:"ro" bson:"ro"` - Ch int `json:"ch" bson:"ch"` - Dz int `json:"dz" bson:"dz"` - Ps int `json:"ps" bson:"ps"` - Mc int `json:"mc" bson:"mc"` - Ax int `json:"ax" bson:"ax"` - Md int `json:"md" bson:"md"` - Hr int `json:"hr" bson:"hr"` - Fi int `json:"fi" bson:"fi"` - Dk int `json:"dk" bson:"dk"` - Tr int `json:"tr" bson:"tr"` - Cz int `json:"cz" bson:"cz"` - Cy int `json:"cy" bson:"cy"` - No int `json:"no" bson:"no"` - At int `json:"at" bson:"at"` - Fo int `json:"fo" bson:"fo"` - Us int `json:"us" bson:"us"` - Tn int `json:"tn" bson:"tn"` - Lv int `json:"lv" bson:"lv"` - Je int `json:"je" bson:"je"` - Ly int `json:"ly" bson:"ly"` - Bg int `json:"bg" bson:"bg"` - Sk int `json:"sk" bson:"sk"` - World int `json:"world" bson:"world"` - Sm int `json:"sm" bson:"sm"` - Gg int `json:"gg" bson:"gg"` - Me int `json:"me" bson:"me"` - It int `json:"it" bson:"it"` - Be int `json:"be" bson:"be"` - Rs int `json:"rs" bson:"rs"` - Si int `json:"si" bson:"si"` - Im int `json:"im" bson:"im"` - Pl int `json:"pl" bson:"pl"` - Gr int `json:"gr" bson:"gr"` - Pt int `json:"pt" bson:"pt"` - Lt int `json:"lt" bson:"lt"` - Mk int `json:"mk" bson:"mk"` - Sj int `json:"sj" bson:"sj"` - Hu int `json:"hu" bson:"hu"` - Li int `json:"li" bson:"li"` - Se int `json:"se" bson:"se"` - Uk int `json:"uk" bson:"uk"` - Il int `json:"il" bson:"il"` - Sy int `json:"sy" bson:"sy"` - Ma int `json:"ma" bson:"ma"` - Ie int `json:"ie" bson:"ie"` - Mt int `json:"mt" bson:"mt"` - Ba int `json:"ba" bson:"ba"` - Eg int `json:"eg" bson:"eg"` - Va int `json:"va" bson:"va"` - Gi int `json:"gi" bson:"gi"` - Ua int `json:"ua" bson:"ua"` - Ee int `json:"ee" bson:"ee"` - Ad int `json:"ad" bson:"ad"` + Lb int `json:"lb" bson:"lb,truncate"` + Es int `json:"es" bson:"es,truncate"` + Fr int `json:"fr" bson:"fr,truncate"` + Lu int `json:"lu" bson:"lu,truncate"` + De int `json:"de" bson:"de,truncate"` + Nl int `json:"nl" bson:"nl,truncate"` + Is int `json:"is" bson:"is,truncate"` + Al int `json:"al" bson:"al,truncate"` + Xk int `json:"xk" bson:"xk,truncate"` + Ro int `json:"ro" bson:"ro,truncate"` + Ch int `json:"ch" bson:"ch,truncate"` + Dz int `json:"dz" bson:"dz,truncate"` + Ps int `json:"ps" bson:"ps,truncate"` + Mc int `json:"mc" bson:"mc,truncate"` + Ax int `json:"ax" bson:"ax,truncate"` + Md int `json:"md" bson:"md,truncate"` + Hr int `json:"hr" bson:"hr,truncate"` + Fi int `json:"fi" bson:"fi,truncate"` + Dk int `json:"dk" bson:"dk,truncate"` + Tr int `json:"tr" bson:"tr,truncate"` + Cz int `json:"cz" bson:"cz,truncate"` + Cy int `json:"cy" bson:"cy,truncate"` + No int `json:"no" bson:"no,truncate"` + At int `json:"at" bson:"at,truncate"` + Fo int `json:"fo" bson:"fo,truncate"` + Us int `json:"us" bson:"us,truncate"` + Tn int `json:"tn" bson:"tn,truncate"` + Lv int `json:"lv" bson:"lv,truncate"` + Je int `json:"je" bson:"je,truncate"` + Ly int `json:"ly" bson:"ly,truncate"` + Bg int `json:"bg" bson:"bg,truncate"` + Sk int `json:"sk" bson:"sk,truncate"` + World int `json:"world" bson:"world,truncate"` + Sm int `json:"sm" bson:"sm,truncate"` + Gg int `json:"gg" bson:"gg,truncate"` + Me int `json:"me" bson:"me,truncate"` + It int `json:"it" bson:"it,truncate"` + Be int `json:"be" bson:"be,truncate"` + Rs int `json:"rs" bson:"rs,truncate"` + Si int `json:"si" bson:"si,truncate"` + Im int `json:"im" bson:"im,truncate"` + Pl int `json:"pl" bson:"pl,truncate"` + Gr int `json:"gr" bson:"gr,truncate"` + Pt int `json:"pt" bson:"pt,truncate"` + Lt int `json:"lt" bson:"lt,truncate"` + Mk int `json:"mk" bson:"mk,truncate"` + Sj int `json:"sj" bson:"sj,truncate"` + Hu int `json:"hu" bson:"hu,truncate"` + Li int `json:"li" bson:"li,truncate"` + Se int `json:"se" bson:"se,truncate"` + Uk int `json:"uk" bson:"uk,truncate"` + Il int `json:"il" bson:"il,truncate"` + Sy int `json:"sy" bson:"sy,truncate"` + Ma int `json:"ma" bson:"ma,truncate"` + Ie int `json:"ie" bson:"ie,truncate"` + Mt int `json:"mt" bson:"mt,truncate"` + Ba int `json:"ba" bson:"ba,truncate"` + Eg int `json:"eg" bson:"eg,truncate"` + Va int `json:"va" bson:"va,truncate"` + Gi int `json:"gi" bson:"gi,truncate"` + Ua int `json:"ua" bson:"ua,truncate"` + Ee int `json:"ee" bson:"ee,truncate"` + Ad int `json:"ad" bson:"ad,truncate"` } `json:"values" bson:"values"` TransportationValues struct { - Cy int `json:"cy" bson:"cy"` - Tr int `json:"tr" bson:"tr"` - Cz int `json:"cz" bson:"cz"` - Dk int `json:"dk" bson:"dk"` - At int `json:"at" bson:"at"` - No int `json:"no" bson:"no"` - Mc int `json:"mc" bson:"mc"` - Ps int `json:"ps" bson:"ps"` - Fi int `json:"fi" bson:"fi"` - Hr int `json:"hr" bson:"hr"` - Md int `json:"md" bson:"md"` - Ax int `json:"ax" bson:"ax"` - Us int `json:"us" bson:"us"` - Fo int `json:"fo" bson:"fo"` - Tn int `json:"tn" bson:"tn"` - Nl int `json:"nl" bson:"nl"` - Is int `json:"is" bson:"is"` - Es int `json:"es" bson:"es"` - Lb int `json:"lb" bson:"lb"` - Fr int `json:"fr" bson:"fr"` - De int `json:"de" bson:"de"` - Lu int `json:"lu" bson:"lu"` - Dz int `json:"dz" bson:"dz"` - Ch int `json:"ch" bson:"ch"` - Xk int `json:"xk" bson:"xk"` - Al int `json:"al" bson:"al"` - Ro int `json:"ro" bson:"ro"` - Se int `json:"se" bson:"se"` - Uk int `json:"uk" bson:"uk"` - Mk int `json:"mk" bson:"mk"` - Sj int `json:"sj" bson:"sj"` - Hu int `json:"hu" bson:"hu"` - Pt int `json:"pt" bson:"pt"` - Lt int `json:"lt" bson:"lt"` - Li int `json:"li" bson:"li"` - Ee int `json:"ee" bson:"ee"` - Ua int `json:"ua" bson:"ua"` - Gi int `json:"gi" bson:"gi"` - Va int `json:"va" bson:"va"` - Ad int `json:"ad" bson:"ad"` - Sy int `json:"sy" bson:"sy"` - Il int `json:"il" bson:"il"` - Ba int `json:"ba" bson:"ba"` - Eg int `json:"eg" bson:"eg"` - Mt int `json:"mt" bson:"mt"` - Ie int `json:"ie" bson:"ie"` - Ma int `json:"ma" bson:"ma"` - Gg int `json:"gg" bson:"gg"` - World int `json:"world" bson:"world"` - Sm int `json:"sm" bson:"sm"` - Be int `json:"be" bson:"be"` - Rs int `json:"rs" bson:"rs"` - It int `json:"it" bson:"it"` - Me int `json:"me" bson:"me"` - Bg int `json:"bg" bson:"bg"` - Ly int `json:"ly" bson:"ly"` - Je int `json:"je" bson:"je"` - Lv int `json:"lv" bson:"lv"` - Sk int `json:"sk" bson:"sk"` - Gr int `json:"gr" bson:"gr"` - Pl int `json:"pl" bson:"pl"` - Im int `json:"im" bson:"im"` - Si int `json:"si" bson:"si"` + Cy int `json:"cy" bson:"cy,truncate"` + Tr int `json:"tr" bson:"tr,truncate"` + Cz int `json:"cz" bson:"cz,truncate"` + Dk int `json:"dk" bson:"dk,truncate"` + At int `json:"at" bson:"at,truncate"` + No int `json:"no" bson:"no,truncate"` + Mc int `json:"mc" bson:"mc,truncate"` + Ps int `json:"ps" bson:"ps,truncate"` + Fi int `json:"fi" bson:"fi,truncate"` + Hr int `json:"hr" bson:"hr,truncate"` + Md int `json:"md" bson:"md,truncate"` + Ax int `json:"ax" bson:"ax,truncate"` + Us int `json:"us" bson:"us,truncate"` + Fo int `json:"fo" bson:"fo,truncate"` + Tn int `json:"tn" bson:"tn,truncate"` + Nl int `json:"nl" bson:"nl,truncate"` + Is int `json:"is" bson:"is,truncate"` + Es int `json:"es" bson:"es,truncate"` + Lb int `json:"lb" bson:"lb,truncate"` + Fr int `json:"fr" bson:"fr,truncate"` + De int `json:"de" bson:"de,truncate"` + Lu int `json:"lu" bson:"lu,truncate"` + Dz int `json:"dz" bson:"dz,truncate"` + Ch int `json:"ch" bson:"ch,truncate"` + Xk int `json:"xk" bson:"xk,truncate"` + Al int `json:"al" bson:"al,truncate"` + Ro int `json:"ro" bson:"ro,truncate"` + Se int `json:"se" bson:"se,truncate"` + Uk int `json:"uk" bson:"uk,truncate"` + Mk int `json:"mk" bson:"mk,truncate"` + Sj int `json:"sj" bson:"sj,truncate"` + Hu int `json:"hu" bson:"hu,truncate"` + Pt int `json:"pt" bson:"pt,truncate"` + Lt int `json:"lt" bson:"lt,truncate"` + Li int `json:"li" bson:"li,truncate"` + Ee int `json:"ee" bson:"ee,truncate"` + Ua int `json:"ua" bson:"ua,truncate"` + Gi int `json:"gi" bson:"gi,truncate"` + Va int `json:"va" bson:"va,truncate"` + Ad int `json:"ad" bson:"ad,truncate"` + Sy int `json:"sy" bson:"sy,truncate"` + Il int `json:"il" bson:"il,truncate"` + Ba int `json:"ba" bson:"ba,truncate"` + Eg int `json:"eg" bson:"eg,truncate"` + Mt int `json:"mt" bson:"mt,truncate"` + Ie int `json:"ie" bson:"ie,truncate"` + Ma int `json:"ma" bson:"ma,truncate"` + Gg int `json:"gg" bson:"gg,truncate"` + World int `json:"world" bson:"world,truncate"` + Sm int `json:"sm" bson:"sm,truncate"` + Be int `json:"be" bson:"be,truncate"` + Rs int `json:"rs" bson:"rs,truncate"` + It int `json:"it" bson:"it,truncate"` + Me int `json:"me" bson:"me,truncate"` + Bg int `json:"bg" bson:"bg,truncate"` + Ly int `json:"ly" bson:"ly,truncate"` + Je int `json:"je" bson:"je,truncate"` + Lv int `json:"lv" bson:"lv,truncate"` + Sk int `json:"sk" bson:"sk,truncate"` + Gr int `json:"gr" bson:"gr,truncate"` + Pl int `json:"pl" bson:"pl,truncate"` + Im int `json:"im" bson:"im,truncate"` + Si int `json:"si" bson:"si,truncate"` } `json:"transportation_values" bson:"transportation_values"` AggregatedOrigins []struct { - Percent int `json:"percent" bson:"percent"` + Percent int `json:"percent" bson:"percent,truncate"` Origin string `json:"origin" bson:"origin"` } `json:"aggregated_origins" bson:"aggregated_origins"` OriginsFromOriginsField []string `json:"origins_from_origins_field" bson:"origins_from_origins_field"` TransportationScores struct { - Ch float64 `json:"ch" bson:"ch"` - Dz float64 `json:"dz" bson:"dz"` - Ro float64 `json:"ro" bson:"ro"` - Xk float64 `json:"xk" bson:"xk"` - Al float64 `json:"al" bson:"al"` - Is float64 `json:"is" bson:"is"` - Nl float64 `json:"nl" bson:"nl"` - De float64 `json:"de" bson:"de"` - Lu float64 `json:"lu" bson:"lu"` - Fr float64 `json:"fr" bson:"fr"` - Lb float64 `json:"lb" bson:"lb"` - Es float64 `json:"es" bson:"es"` - Tn float64 `json:"tn" bson:"tn"` - Us float64 `json:"us" bson:"us"` - Fo float64 `json:"fo" bson:"fo"` - At float64 `json:"at" bson:"at"` - No float64 `json:"no" bson:"no"` - Cy float64 `json:"cy" bson:"cy"` - Dk float64 `json:"dk" bson:"dk"` - Tr float64 `json:"tr" bson:"tr"` - Cz float64 `json:"cz" bson:"cz"` - Hr float64 `json:"hr" bson:"hr"` - Fi float64 `json:"fi" bson:"fi"` - Ax float64 `json:"ax" bson:"ax"` - Md float64 `json:"md" bson:"md"` - Ps float64 `json:"ps" bson:"ps"` - Mc float64 `json:"mc" bson:"mc"` - Pl float64 `json:"pl" bson:"pl"` - Gr float64 `json:"gr" bson:"gr"` - Si float64 `json:"si" bson:"si"` - Im float64 `json:"im" bson:"im"` - Rs float64 `json:"rs" bson:"rs"` - Be float64 `json:"be" bson:"be"` - Me float64 `json:"me" bson:"me"` - It float64 `json:"it" bson:"it"` - Sm float64 `json:"sm" bson:"sm"` - World float64 `json:"world" bson:"world"` - Gg float64 `json:"gg" bson:"gg"` - Sk float64 `json:"sk" bson:"sk"` - Lv float64 `json:"lv" bson:"lv"` - Je float64 `json:"je" bson:"je"` - Ly float64 `json:"ly" bson:"ly"` - Bg float64 `json:"bg" bson:"bg"` - Ad float64 `json:"ad" bson:"ad"` - Ee float64 `json:"ee" bson:"ee"` - Va float64 `json:"va" bson:"va"` - Gi float64 `json:"gi" bson:"gi"` - Ua float64 `json:"ua" bson:"ua"` - Eg float64 `json:"eg" bson:"eg"` - Ba float64 `json:"ba" bson:"ba"` - Ie float64 `json:"ie" bson:"ie"` - Ma float64 `json:"ma" bson:"ma"` - Mt float64 `json:"mt" bson:"mt"` - Il float64 `json:"il" bson:"il"` - Sy float64 `json:"sy" bson:"sy"` - Uk float64 `json:"uk" bson:"uk"` - Se float64 `json:"se" bson:"se"` - Li float64 `json:"li" bson:"li"` - Sj float64 `json:"sj" bson:"sj"` - Mk float64 `json:"mk" bson:"mk"` - Hu float64 `json:"hu" bson:"hu"` - Pt float64 `json:"pt" bson:"pt"` - Lt float64 `json:"lt" bson:"lt"` + Ch float64 `json:"ch" bson:"ch,truncate"` + Dz float64 `json:"dz" bson:"dz,truncate"` + Ro float64 `json:"ro" bson:"ro,truncate"` + Xk float64 `json:"xk" bson:"xk,truncate"` + Al float64 `json:"al" bson:"al,truncate"` + Is float64 `json:"is" bson:"is,truncate"` + Nl float64 `json:"nl" bson:"nl,truncate"` + De float64 `json:"de" bson:"de,truncate"` + Lu float64 `json:"lu" bson:"lu,truncate"` + Fr float64 `json:"fr" bson:"fr,truncate"` + Lb float64 `json:"lb" bson:"lb,truncate"` + Es float64 `json:"es" bson:"es,truncate"` + Tn float64 `json:"tn" bson:"tn,truncate"` + Us float64 `json:"us" bson:"us,truncate"` + Fo float64 `json:"fo" bson:"fo,truncate"` + At float64 `json:"at" bson:"at,truncate"` + No float64 `json:"no" bson:"no,truncate"` + Cy float64 `json:"cy" bson:"cy,truncate"` + Dk float64 `json:"dk" bson:"dk,truncate"` + Tr float64 `json:"tr" bson:"tr,truncate"` + Cz float64 `json:"cz" bson:"cz,truncate"` + Hr float64 `json:"hr" bson:"hr,truncate"` + Fi float64 `json:"fi" bson:"fi,truncate"` + Ax float64 `json:"ax" bson:"ax,truncate"` + Md float64 `json:"md" bson:"md,truncate"` + Ps float64 `json:"ps" bson:"ps,truncate"` + Mc float64 `json:"mc" bson:"mc,truncate"` + Pl float64 `json:"pl" bson:"pl,truncate"` + Gr float64 `json:"gr" bson:"gr,truncate"` + Si float64 `json:"si" bson:"si,truncate"` + Im float64 `json:"im" bson:"im,truncate"` + Rs float64 `json:"rs" bson:"rs,truncate"` + Be float64 `json:"be" bson:"be,truncate"` + Me float64 `json:"me" bson:"me,truncate"` + It float64 `json:"it" bson:"it,truncate"` + Sm float64 `json:"sm" bson:"sm,truncate"` + World float64 `json:"world" bson:"world,truncate"` + Gg float64 `json:"gg" bson:"gg,truncate"` + Sk float64 `json:"sk" bson:"sk,truncate"` + Lv float64 `json:"lv" bson:"lv,truncate"` + Je float64 `json:"je" bson:"je,truncate"` + Ly float64 `json:"ly" bson:"ly,truncate"` + Bg float64 `json:"bg" bson:"bg,truncate"` + Ad float64 `json:"ad" bson:"ad,truncate"` + Ee float64 `json:"ee" bson:"ee,truncate"` + Va float64 `json:"va" bson:"va,truncate"` + Gi float64 `json:"gi" bson:"gi,truncate"` + Ua float64 `json:"ua" bson:"ua,truncate"` + Eg float64 `json:"eg" bson:"eg,truncate"` + Ba float64 `json:"ba" bson:"ba,truncate"` + Ie float64 `json:"ie" bson:"ie,truncate"` + Ma float64 `json:"ma" bson:"ma,truncate"` + Mt float64 `json:"mt" bson:"mt,truncate"` + Il float64 `json:"il" bson:"il,truncate"` + Sy float64 `json:"sy" bson:"sy,truncate"` + Uk float64 `json:"uk" bson:"uk,truncate"` + Se float64 `json:"se" bson:"se,truncate"` + Li float64 `json:"li" bson:"li,truncate"` + Sj float64 `json:"sj" bson:"sj,truncate"` + Mk float64 `json:"mk" bson:"mk,truncate"` + Hu float64 `json:"hu" bson:"hu,truncate"` + Pt float64 `json:"pt" bson:"pt,truncate"` + Lt float64 `json:"lt" bson:"lt,truncate"` } `json:"transportation_scores" bson:"transportation_scores"` Warning string `json:"warning" bson:"warning"` - EpiScore int `json:"epi_score" bson:"epi_score"` + EpiScore int `json:"epi_score" bson:"epi_score,truncate"` OriginsFromCategories []string `json:"origins_from_categories" bson:"origins_from_categories"` } `json:"origins_of_ingredients" bson:"origins_of_ingredients"` ThreatenedSpecies struct { Warning string `json:"warning" bson:"warning"` } `json:"threatened_species" bson:"threatened_species"` ProductionSystem struct { - Labels []interface{} `json:"labels" bson:"labels"` - Value int `json:"value" bson:"value"` + Labels []interface{} `json:"labels" bson:"labels,truncate"` + Value int `json:"value" bson:"value,truncate"` Warning string `json:"warning" bson:"warning"` } `json:"production_system" bson:"production_system"` Packaging struct { Warning string `json:"warning" bson:"warning"` - Value int `json:"value" bson:"value"` + Value int `json:"value" bson:"value,truncate"` } `json:"packaging" bson:"packaging"` } `json:"adjustments" bson:"adjustments"` Grade string `json:"grade" bson:"grade"` } `json:"environmental_score_data" bson:"environmental_score_data"` - UnknownNutrientsTags []interface{} `json:"unknown_nutrients_tags" bson:"unknown_nutrients_tags"` - ScansN int `json:"scans_n" bson:"scans_n"` - WeighersTags []interface{} `json:"weighers_tags" bson:"weighers_tags"` + UnknownNutrientsTags []interface{} `json:"unknown_nutrients_tags" bson:"unknown_nutrients_tags,truncate"` + ScansN int `json:"scans_n" bson:"scans_n,truncate"` + WeighersTags []interface{} `json:"weighers_tags" bson:"weighers_tags,truncate"` CategoriesProperties struct { } `json:"categories_properties" bson:"categories_properties"` BrandsLc string `json:"brands_lc" bson:"brands_lc"` ProductType string `json:"product_type" bson:"product_type"` NoNutritionData string `json:"no_nutrition_data" bson:"no_nutrition_data"` - Packagings []interface{} `json:"packagings" bson:"packagings"` + Packagings []interface{} `json:"packagings" bson:"packagings,truncate"` PackagingsMaterials struct { } `json:"packagings_materials" bson:"packagings_materials"` DataSourcesTags []string `json:"data_sources_tags" bson:"data_sources_tags"` NutriscoreGrade string `json:"nutriscore_grade" bson:"nutriscore_grade"` NovaGroupsTags []string `json:"nova_groups_tags" bson:"nova_groups_tags"` AllergensFromUser string `json:"allergens_from_user" bson:"allergens_from_user"` - LastModifiedT int `json:"last_modified_t" bson:"last_modified_t"` + LastModifiedT int `json:"last_modified_t" bson:"last_modified_t,truncate"` CountriesHierarchy []string `json:"countries_hierarchy" bson:"countries_hierarchy"` - TracesTags []interface{} `json:"traces_tags" bson:"traces_tags"` - Rev int `json:"rev" bson:"rev"` + TracesTags []interface{} `json:"traces_tags" bson:"traces_tags,truncate"` + Rev int `json:"rev" bson:"rev,truncate"` Nutriments struct { - Energy100G int `json:"energy_100g" bson:"energy_100g"` - Fat int `json:"fat" bson:"fat"` - EnergyKcal int `json:"energy-kcal" bson:"energy-kcal"` - SugarsValue float64 `json:"sugars_value" bson:"sugars_value"` + Energy100G int `json:"energy_100g" bson:"energy_100g,truncate"` + Fat int `json:"fat" bson:"fat,truncate"` + EnergyKcal int `json:"energy-kcal" bson:"energy-kcal,truncate"` + SugarsValue float64 `json:"sugars_value" bson:"sugars_value,truncate"` SugarsUnit string `json:"sugars_unit" bson:"sugars_unit"` - Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates"` - Carbohydrates100G float64 `json:"carbohydrates_100g" bson:"carbohydrates_100g"` - Energy int `json:"energy" bson:"energy"` - SugarsServing float64 `json:"sugars_serving" bson:"sugars_serving"` - Fat100G int `json:"fat_100g" bson:"fat_100g"` - ProteinsValue int `json:"proteins_value" bson:"proteins_value"` + Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates,truncate"` + Carbohydrates100G float64 `json:"carbohydrates_100g" bson:"carbohydrates_100g,truncate"` + Energy int `json:"energy" bson:"energy,truncate"` + SugarsServing float64 `json:"sugars_serving" bson:"sugars_serving,truncate"` + Fat100G int `json:"fat_100g" bson:"fat_100g,truncate"` + ProteinsValue int `json:"proteins_value" bson:"proteins_value,truncate"` EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"` - CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value"` - Sugars100G float64 `json:"sugars_100g" bson:"sugars_100g"` + CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"` + Sugars100G float64 `json:"sugars_100g" bson:"sugars_100g,truncate"` FatUnit string `json:"fat_unit" bson:"fat_unit"` - CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving"` - Proteins int `json:"proteins" bson:"proteins"` - EnergyValue int `json:"energy_value" bson:"energy_value"` + CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` + Proteins int `json:"proteins" bson:"proteins,truncate"` + EnergyValue int `json:"energy_value" bson:"energy_value,truncate"` EnergyUnit string `json:"energy_unit" bson:"energy_unit"` ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"` - EnergyKcalValue int `json:"energy-kcal_value" bson:"energy-kcal_value"` - EnergyKcal100G int `json:"energy-kcal_100g" bson:"energy-kcal_100g"` - EnergyKcalServing float64 `json:"energy-kcal_serving" bson:"energy-kcal_serving"` - FatServing int `json:"fat_serving" bson:"fat_serving"` + EnergyKcalValue int `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"` + EnergyKcal100G int `json:"energy-kcal_100g" bson:"energy-kcal_100g,truncate"` + EnergyKcalServing float64 `json:"energy-kcal_serving" bson:"energy-kcal_serving,truncate"` + FatServing int `json:"fat_serving" bson:"fat_serving,truncate"` CarbohydratesUnit string `json:"carbohydrates_unit" bson:"carbohydrates_unit"` - FatValue int `json:"fat_value" bson:"fat_value"` - Proteins100G int `json:"proteins_100g" bson:"proteins_100g"` - ProteinsServing int `json:"proteins_serving" bson:"proteins_serving"` - EnergyKcalValueComputed int `json:"energy-kcal_value_computed" bson:"energy-kcal_value_computed"` - EnergyServing int `json:"energy_serving" bson:"energy_serving"` - Sugars float64 `json:"sugars" bson:"sugars"` + FatValue int `json:"fat_value" bson:"fat_value,truncate"` + Proteins100G int `json:"proteins_100g" bson:"proteins_100g,truncate"` + ProteinsServing int `json:"proteins_serving" bson:"proteins_serving,truncate"` + EnergyKcalValueComputed int `json:"energy-kcal_value_computed" bson:"energy-kcal_value_computed,truncate"` + EnergyServing int `json:"energy_serving" bson:"energy_serving,truncate"` + Sugars float64 `json:"sugars" bson:"sugars,truncate"` } `json:"nutriments" bson:"nutriments"` ServingQuantityUnit string `json:"serving_quantity_unit" bson:"serving_quantity_unit"` CountriesLc string `json:"countries_lc" bson:"countries_lc"` @@ -335,70 +335,70 @@ type Product struct { Nutriscore struct { Num2021 struct { Data struct { - Sugars float64 `json:"sugars" bson:"sugars"` - Energy int `json:"energy" bson:"energy"` - IsBeverage int `json:"is_beverage" bson:"is_beverage"` - IsWater int `json:"is_water" bson:"is_water"` - Sodium interface{} `json:"sodium" bson:"sodium"` - IsCheese int `json:"is_cheese" bson:"is_cheese"` - IsFat int `json:"is_fat" bson:"is_fat"` - Proteins int `json:"proteins" bson:"proteins"` - SaturatedFat int `json:"saturated_fat" bson:"saturated_fat"` - Fiber int `json:"fiber" bson:"fiber"` - SaturatedFatRatio int `json:"saturated_fat_ratio" bson:"saturated_fat_ratio"` - FruitsVegetablesNutsColzaWalnutOliveOils int `json:"fruits_vegetables_nuts_colza_walnut_olive_oils" bson:"fruits_vegetables_nuts_colza_walnut_olive_oils"` + Sugars float64 `json:"sugars" bson:"sugars,truncate"` + Energy int `json:"energy" bson:"energy,truncate"` + IsBeverage int `json:"is_beverage" bson:"is_beverage,truncate"` + IsWater int `json:"is_water" bson:"is_water,truncate"` + Sodium interface{} `json:"sodium" bson:"sodium,truncate"` + IsCheese int `json:"is_cheese" bson:"is_cheese,truncate"` + IsFat int `json:"is_fat" bson:"is_fat,truncate"` + Proteins int `json:"proteins" bson:"proteins,truncate"` + SaturatedFat int `json:"saturated_fat" bson:"saturated_fat,truncate"` + Fiber int `json:"fiber" bson:"fiber,truncate"` + SaturatedFatRatio int `json:"saturated_fat_ratio" bson:"saturated_fat_ratio,truncate"` + FruitsVegetablesNutsColzaWalnutOliveOils int `json:"fruits_vegetables_nuts_colza_walnut_olive_oils" bson:"fruits_vegetables_nuts_colza_walnut_olive_oils,truncate"` } `json:"data" bson:"data"` Grade string `json:"grade" bson:"grade"` - NutriscoreComputed int `json:"nutriscore_computed" bson:"nutriscore_computed"` - NutriscoreApplicable int `json:"nutriscore_applicable" bson:"nutriscore_applicable"` - NutrientsAvailable int `json:"nutrients_available" bson:"nutrients_available"` - CategoryAvailable int `json:"category_available" bson:"category_available"` + NutriscoreComputed int `json:"nutriscore_computed" bson:"nutriscore_computed,truncate"` + NutriscoreApplicable int `json:"nutriscore_applicable" bson:"nutriscore_applicable,truncate"` + NutrientsAvailable int `json:"nutrients_available" bson:"nutrients_available,truncate"` + CategoryAvailable int `json:"category_available" bson:"category_available,truncate"` } `json:"2021" bson:"2021"` Num2023 struct { - NutriscoreComputed int `json:"nutriscore_computed" bson:"nutriscore_computed"` + NutriscoreComputed int `json:"nutriscore_computed" bson:"nutriscore_computed,truncate"` Grade string `json:"grade" bson:"grade"` Data struct { - Proteins int `json:"proteins" bson:"proteins"` - IsFatOilNutsSeeds int `json:"is_fat_oil_nuts_seeds" bson:"is_fat_oil_nuts_seeds"` - SaturatedFat int `json:"saturated_fat" bson:"saturated_fat"` - Fiber interface{} `json:"fiber" bson:"fiber"` - FruitsVegetablesLegumes interface{} `json:"fruits_vegetables_legumes" bson:"fruits_vegetables_legumes"` - SaturatedFatRatio int `json:"saturated_fat_ratio" bson:"saturated_fat_ratio"` - Salt interface{} `json:"salt" bson:"salt"` - Sugars float64 `json:"sugars" bson:"sugars"` - IsRedMeatProduct int `json:"is_red_meat_product" bson:"is_red_meat_product"` - IsBeverage int `json:"is_beverage" bson:"is_beverage"` - Energy int `json:"energy" bson:"energy"` - IsWater int `json:"is_water" bson:"is_water"` - IsCheese int `json:"is_cheese" bson:"is_cheese"` + Proteins int `json:"proteins" bson:"proteins,truncate"` + IsFatOilNutsSeeds int `json:"is_fat_oil_nuts_seeds" bson:"is_fat_oil_nuts_seeds,truncate"` + SaturatedFat int `json:"saturated_fat" bson:"saturated_fat,truncate"` + Fiber interface{} `json:"fiber" bson:"fiber,truncate"` + FruitsVegetablesLegumes interface{} `json:"fruits_vegetables_legumes" bson:"fruits_vegetables_legumes,truncate"` + SaturatedFatRatio int `json:"saturated_fat_ratio" bson:"saturated_fat_ratio,truncate"` + Salt interface{} `json:"salt" bson:"salt,truncate"` + Sugars float64 `json:"sugars" bson:"sugars,truncate"` + IsRedMeatProduct int `json:"is_red_meat_product" bson:"is_red_meat_product,truncate"` + IsBeverage int `json:"is_beverage" bson:"is_beverage,truncate"` + Energy int `json:"energy" bson:"energy,truncate"` + IsWater int `json:"is_water" bson:"is_water,truncate"` + IsCheese int `json:"is_cheese" bson:"is_cheese,truncate"` } `json:"data" bson:"data"` - CategoryAvailable int `json:"category_available" bson:"category_available"` - NutrientsAvailable int `json:"nutrients_available" bson:"nutrients_available"` - NutriscoreApplicable int `json:"nutriscore_applicable" bson:"nutriscore_applicable"` + CategoryAvailable int `json:"category_available" bson:"category_available,truncate"` + NutrientsAvailable int `json:"nutrients_available" bson:"nutrients_available,truncate"` + NutriscoreApplicable int `json:"nutriscore_applicable" bson:"nutriscore_applicable,truncate"` } `json:"2023" bson:"2023"` } `json:"nutriscore" bson:"nutriscore"` - Completeness float64 `json:"completeness" bson:"completeness"` + Completeness float64 `json:"completeness" bson:"completeness,truncate"` ProductName string `json:"product_name" bson:"product_name"` - PackagingMaterialsTags []interface{} `json:"packaging_materials_tags" bson:"packaging_materials_tags"` + PackagingMaterialsTags []interface{} `json:"packaging_materials_tags" bson:"packaging_materials_tags,truncate"` Keywords []string `json:"_keywords" bson:"_keywords"` - LastUpdatedT int `json:"last_updated_t" bson:"last_updated_t"` + LastUpdatedT int `json:"last_updated_t" bson:"last_updated_t,truncate"` EntryDatesTags []string `json:"entry_dates_tags" bson:"entry_dates_tags"` LanguagesHierarchy []string `json:"languages_hierarchy" bson:"languages_hierarchy"` - MainCountriesTags []interface{} `json:"main_countries_tags" bson:"main_countries_tags"` + MainCountriesTags []interface{} `json:"main_countries_tags" bson:"main_countries_tags,truncate"` DataQualityInfoTags []string `json:"data_quality_info_tags" bson:"data_quality_info_tags"` Nutriscore2021Tags []string `json:"nutriscore_2021_tags" bson:"nutriscore_2021_tags"` MaxImgid string `json:"max_imgid" bson:"max_imgid"` StatesTags []string `json:"states_tags" bson:"states_tags"` - NutritionScoreWarningNoFruitsVegetablesNuts int `json:"nutrition_score_warning_no_fruits_vegetables_nuts" bson:"nutrition_score_warning_no_fruits_vegetables_nuts"` + NutritionScoreWarningNoFruitsVegetablesNuts int `json:"nutrition_score_warning_no_fruits_vegetables_nuts" bson:"nutrition_score_warning_no_fruits_vegetables_nuts,truncate"` EnvironmentalScoreGrade string `json:"environmental_score_grade" bson:"environmental_score_grade"` PopularityTags []string `json:"popularity_tags" bson:"popularity_tags"` - PackagingRecyclingTags []interface{} `json:"packaging_recycling_tags" bson:"packaging_recycling_tags"` - CheckersTags []interface{} `json:"checkers_tags" bson:"checkers_tags"` + PackagingRecyclingTags []interface{} `json:"packaging_recycling_tags" bson:"packaging_recycling_tags,truncate"` + CheckersTags []interface{} `json:"checkers_tags" bson:"checkers_tags,truncate"` NutrientLevels struct { } `json:"nutrient_levels" bson:"nutrient_levels"` PnnsGroups1Tags []string `json:"pnns_groups_1_tags" bson:"pnns_groups_1_tags"` LastEditDatesTags []string `json:"last_edit_dates_tags" bson:"last_edit_dates_tags"` - NutritionScoreWarningNoFiber int `json:"nutrition_score_warning_no_fiber" bson:"nutrition_score_warning_no_fiber"` + NutritionScoreWarningNoFiber int `json:"nutrition_score_warning_no_fiber" bson:"nutrition_score_warning_no_fiber,truncate"` InformersTags []string `json:"informers_tags" bson:"informers_tags"` PnnsGroups2 string `json:"pnns_groups_2" bson:"pnns_groups_2"` BrandsTags []string `json:"brands_tags" bson:"brands_tags"` @@ -406,6 +406,6 @@ type Product struct { PnnsGroups1 string `json:"pnns_groups_1" bson:"pnns_groups_1"` EcoscoreTags []string `json:"ecoscore_tags" bson:"ecoscore_tags"` PnnsGroups2Tags []string `json:"pnns_groups_2_tags" bson:"pnns_groups_2_tags"` - PopularityKey int `json:"popularity_key" bson:"popularity_key"` - AllergensTags []interface{} `json:"allergens_tags" bson:"allergens_tags"` + PopularityKey int `json:"popularity_key" bson:"popularity_key,truncate"` + AllergensTags []interface{} `json:"allergens_tags" bson:"allergens_tags,truncate"` } From 472e20960ea8fc6ec52d6ab855a005c678628cad Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:39:22 +0100 Subject: [PATCH 5/6] Made search endpoint return product list instead of bson to json --- internal/database/product/queries.go | 19 +++++-------------- internal/handlers/product/get.go | 9 +++++++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/internal/database/product/queries.go b/internal/database/product/queries.go index a2eb2af..21434f6 100644 --- a/internal/database/product/queries.go +++ b/internal/database/product/queries.go @@ -25,7 +25,7 @@ func GetProductByID(db *mongo.Client, id string) (*Product, error) { return product, nil } -func SearchProductByName(db *mongo.Client, query string, limit int) (string, error) { +func SearchProductByName(db *mongo.Client, query string, limit int) (*[]Product, error) { filter := bson.M{ "$text": bson.M{ "$search": strings.TrimSpace(query), @@ -47,23 +47,14 @@ func SearchProductByName(db *mongo.Client, query string, limit int) (string, err cursor, err := db.Database("off").Collection("products").Find(context.TODO(), filter, filterOptions) if err != nil { - return "", fmt.Errorf("failed to search products: %v", err) + return nil, fmt.Errorf("failed to search products: %v", err) } defer cursor.Close(context.TODO()) - var results []bson.M + var results []Product if err = cursor.All(context.TODO(), &results); err != nil { - return "", fmt.Errorf("failed to decode products: %v", err) + return nil, fmt.Errorf("failed to decode products: %v", err) } - resultsBson := bson.M{ - "results": results, - } - - jsonBytes, err := bson.MarshalExtJSON(resultsBson, true, false) - if err != nil { - return "", fmt.Errorf("failed to marshal products to JSON: %v", err) - } - - return string(jsonBytes), nil + return &results, nil } diff --git a/internal/handlers/product/get.go b/internal/handlers/product/get.go index 65c3d29..268d4a4 100644 --- a/internal/handlers/product/get.go +++ b/internal/handlers/product/get.go @@ -30,12 +30,17 @@ func (p *ProductController) Get(c *gin.Context) { return } - productsJSON, err := product.SearchProductByName(p.DB, query, int(limit)) + products, err := product.SearchProductByName(p.DB, query, int(limit)) if err != nil { log.Println(err) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } + if products == nil { + log.Println("Products was nil?!") + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "products was nil."}) + return + } - c.JSON(http.StatusOK, gin.H{"products": productsJSON}) + c.JSON(http.StatusOK, gin.H{"products": *products}) } From c2ff4c91cc8a3f36fd7a26e757b00b1fdb0fd2d2 Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:47:09 +0100 Subject: [PATCH 6/6] Update internal/handlers/product/get.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- internal/handlers/product/get.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/handlers/product/get.go b/internal/handlers/product/get.go index 268d4a4..ee78653 100644 --- a/internal/handlers/product/get.go +++ b/internal/handlers/product/get.go @@ -42,5 +42,5 @@ func (p *ProductController) Get(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{"products": *products}) + c.JSON(http.StatusOK, gin.H{"products": products}) }