Skip to content

Commit a9d8fad

Browse files
docs: clarify query.batch example variable naming
1 parent 3cbaac2 commit a9d8fad

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

documentation/docs/20-core-concepts/60-remote-functions.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,23 @@ import * as v from 'valibot';
190190
import { query } from '$app/server';
191191
import * as db from '$lib/server/database';
192192

193-
export const getWeather = query.batch(v.string(), async (cities) => {
193+
export const getWeather = query.batch(v.string(), async (cityIds) => {
194194
const weather = await db.sql`
195-
SELECT * FROM weather
196-
WHERE city = ANY(${cities})
195+
SELECT city_id, temperature, conditions
196+
FROM weather
197+
WHERE city_id = ANY(${cityIds})
197198
`;
198-
const lookup = new Map(weather.map(w => [w.city, w]));
199+
const lookup = new Map(weather.map((w) => [w.city_id, w]));
199200

200-
return (city) => lookup.get(city);
201+
return (cityId) => lookup.get(cityId);
201202
});
202203
```
203204
204205
```svelte
205206
<!--- file: Weather.svelte --->
206207
<script>
207208
import CityWeather from './CityWeather.svelte';
208-
import { getWeather } from './weather.remote.js';
209+
import { getWeather } from './weather.remote';
209210

210211
let { cities } = $props();
211212
let limit = $state(5);

0 commit comments

Comments
 (0)