Skip to content

Commit

Permalink
docs(guide): add information about static parameters (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandesai01 authored Oct 9, 2024
1 parent 75f04e2 commit ad84a26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/1.guide/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;
// Query for users
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;
console.log(rows);

// Using static parameters
const tableName = "users";
const { rows } = await db.sql`SELECT * FROM {${tableName}} WHERE id = ${userId}`;
console.log(rows);
```

> [!IMPORTANT]
> **Static Parameters** are a way to use string-literals other than places where prepared statements are supported, for eg. table name. **DO NOT USE** static parameters from untrusted source such as request body. **STATIC PARAMETERS ARE NOT SANITISED**
## Next steps

:read-more{to="/connectors"}
Expand Down
2 changes: 1 addition & 1 deletion docs/1.guide/3.http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ icon: material-symbols:http

# HTTP Server

> Expose SQL databases over (secure) HTTP as a restfu API for edge runtimes!
> Expose SQL databases over (secure) HTTP as a restful API for edge runtimes!
> [!NOTE]
> 🚀 This feature is planned! Follow up [unjs/db0#6](https://github.com/unjs/db0/issues/6)

0 comments on commit ad84a26

Please sign in to comment.