Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/site/Executing-database-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,42 @@ Example use:
```ts
const result = await repository.execute('SELECT * FROM Products');
```
## Examples

### MySQL

Use parameterized queries to avoid SQL injection attacks.

```ts
const result = await repository.execute(
'SELECT * FROM Products WHERE id = ?',
[productId]
);
```

### PostgreSQL

```ts
const result = await repository.execute(
'SELECT * FROM Products WHERE id = $1',
[productId]
);
```

### MongoDB

```ts
const result = await repository.execute(
'MyCollection',
'aggregate',
[
{$unwind: '$data'},
{$out: 'tempData'},
]
);
```

Use parameterized queries whenever possible instead of constructing SQL strings manually.

See API docs for parameter reference, additional information and examples:

Expand Down
Loading