Skip to content

Conversation

@RazinShafayet2007
Copy link
Contributor

Fixes #15278

This PR clarifies the query.batch example in the Remote Functions documentation.
The previous example used the variable names cities and city, which made it unclear that the inputs are actually string IDs (for example, city.id), not city objects or names. This ambiguity can be confusing, especially for readers new to query.batch.

The example has been updated with clearer, more explicit naming:

  • citiescityIds
  • citycityId

The SQL query and lookup map were also adjusted to use city_id, aligning the example with common database schemas and making it consistent with how the data is consumed in the accompanying component.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link

changeset-bot bot commented Feb 8, 2026

⚠️ No Changeset found

Latest commit: 2d1f6e9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot
Copy link

@RazinShafayet2007 RazinShafayet2007 changed the title docs: clarify <code>query.batch</code> example variable naming docs: clarify query.batch example variable naming Feb 8, 2026

export const getWeather = query.batch(v.string(), async (cities) => {
export const getWeather = query.batch(v.string(), async (cityIds) => {
const weather = await db.sql`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be weathers to clarify that it is an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I was just focused on citiescityIds and citycityId. To make it clearer that the SQL result is an array, I’ll rename weather to weatherData.

@dummdidumm
Copy link
Member

Closing since this also renamed all the .remote endings - it's ok to use AI but you gotta double check your work. Opening a PR with the changes we wanna keep

@dummdidumm dummdidumm closed this Feb 9, 2026
```

> [!NOTE] The preflight schema can be the same object as your server-side schema, if appropriate, though it won't be able to do server-side checks like 'this value already exists in the database'. Note that you cannot export a schema from a `.remote.ts` or `.remote.js` file, so the schema must either be exported from a shared module, or from a `<script module>` block in the component containing the `<form>`.
> [!NOTE] The preflight schema can be the same object as your server-side schema, if appropriate, though it won't be able to do server-side checks like 'this value already exists in the database'. Note that you cannot export a schema from a `.ts` or `.js` file, so the schema must either be exported from a shared module, or from a `<script module>` block in the component containing the `<form>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> [!NOTE] The preflight schema can be the same object as your server-side schema, if appropriate, though it won't be able to do server-side checks like 'this value already exists in the database'. Note that you cannot export a schema from a `.ts` or `.js` file, so the schema must either be exported from a shared module, or from a `<script module>` block in the component containing the `<form>`.
> [!NOTE] The preflight schema can be the same object as your server-side schema, if appropriate, though it won't be able to do server-side checks like 'this value already exists in the database'. Note that you cannot export a schema from a `.remote.ts` or `.remote.js` file, so the schema must either be exported from a shared module, or from a `<script module>` block in the component containing the `<form>`.

Documentation note incorrectly states schemas cannot be exported from any .ts or .js file, when the restriction is specific to .remote.ts or .remote.js files

Fix on Vercel


```js
/// file: data.remote.js
/// file: data.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple server-side file examples in the form/Fields section incorrectly use data.js and src/routes/shop/data.js extensions instead of the required data.remote.js and src/routes/shop/data.remote.js extensions

Fix on Vercel

```svelte
<script>
import { createProfile } from './data.remote';
import { createProfile } from './data';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation contains inconsistent import statements that omit the .remote extension, contradicting the stated file naming convention.

Fix on Vercel

@RazinShafayet2007 RazinShafayet2007 deleted the docs/query-batch-clarify-example branch February 9, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: clarify query.batch example code

3 participants