-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
docs: clarify query.batch example variable naming #15282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: clarify query.batch example variable naming #15282
Conversation
|
|
|
||
| export const getWeather = query.batch(v.string(), async (cities) => { | ||
| export const getWeather = query.batch(v.string(), async (cityIds) => { | ||
| const weather = await db.sql` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 cities → cityIds and city → cityId. To make it clearer that the SQL result is an array, I’ll rename weather to weatherData.
|
Closing since this also renamed all the |
| ``` | ||
|
|
||
| > [!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>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| > [!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
|
|
||
| ```js | ||
| /// file: data.remote.js | ||
| /// file: data.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```svelte | ||
| <script> | ||
| import { createProfile } from './data.remote'; | ||
| import { createProfile } from './data'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #15278
This PR clarifies the
query.batchexample in the Remote Functions documentation.The previous example used the variable names
citiesandcity, 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 toquery.batch.The example has been updated with clearer, more explicit naming:
cities→cityIdscity→cityIdThe 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:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits