mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
26 lines
475 B
Text
26 lines
475 B
Text
|
---
|
||
|
/// <reference path="../../.astro/db-types.d.ts" />
|
||
|
import { Recipe, Ingredient, db, eq } from 'astro:db';
|
||
|
|
||
|
const ingredientsByRecipe = await db
|
||
|
.select({
|
||
|
name: Ingredient.name,
|
||
|
recipeName: Recipe.title,
|
||
|
})
|
||
|
.from(Ingredient)
|
||
|
.innerJoin(Recipe, eq(Ingredient.recipeId, Recipe.id));
|
||
|
|
||
|
console.log(ingredientsByRecipe);
|
||
|
---
|
||
|
|
||
|
<h2>Shopping list</h2>
|
||
|
<ul>
|
||
|
{
|
||
|
ingredientsByRecipe.map(({ name, recipeName }) => (
|
||
|
<li>
|
||
|
{name} ({recipeName})
|
||
|
</li>
|
||
|
))
|
||
|
}
|
||
|
</ul>
|