Log several foods
add_foodsLog multiple catalog foods in one meal with a single write, e.g. a whole breakfast. Validates every item before saving, so if one is wrong nothing is logged.
Instructions
Log several catalog foods in one meal with one write, e.g. a whole breakfast. Each item takes food_id, food_type, quantity and measure_id or unit as add_food does, and is checked the same way before anything is written (one read per item with measure_id or unit): when one is wrong, nothing is logged and the error names it as items[index]. Returns the rows (row_id, food_id, measure_id, measure_name, measure_quantity) in the order of items; they are not read back, data.ok says the sync accepted them. Each call adds rows unless row_id is reused.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Day as YYYY-MM-DD; when the user says today, yesterday, this week or a weekday, call get_today and count from its date. | |
| meal | Yes | Meal slot. The keys are fixed, but users rename their meals in the app: match the user's words against get_day's meal_name and pass that meal's meal_key. Only the meals get_day lists exist. | |
| eaten | No | Sets every row: true (the default) when the user ate them or just asks to log them; false only when they plan ahead. | |
| items | Yes | The foods, each as add_food takes it. | |
| row_id | No | Optional UUID version 1 the rows' row_ids are derived from; omit it to get a new one. Repeating the add with the same row_id and arguments writes the same rows again instead of new ones: when a failed add's error has a retry_row_id, repeat it with that row_id. Never a row_id from get_day. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| data | No | ||
| error | No | describe_error() of what went wrong; docs/AGENTS.md, Results and errors. |