Skip to content

Commit 0459df9

Browse files
committed
docs: add Repository.execute examples
Signed-off-by: vivekpatil017 <vivekpatil9902@gmail.com> style: format documentation with Prettier
1 parent 25502ec commit 0459df9

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

docs/site/Executing-database-commands.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,39 @@ const result = await repository.execute('MyCollection', 'aggregate', [
6363
Use parameterized queries whenever possible instead of constructing SQL strings
6464
manually.
6565

66+
## Examples
67+
68+
### MySQL
69+
70+
Use parameterized queries to avoid SQL injection attacks.
71+
72+
```ts
73+
const result = await repository.execute('SELECT * FROM Products WHERE id = ?', [
74+
productId,
75+
]);
76+
```
77+
78+
### PostgreSQL
79+
80+
```ts
81+
const result = await repository.execute(
82+
'SELECT * FROM Products WHERE id = $1',
83+
[productId],
84+
);
85+
```
86+
87+
### MongoDB
88+
89+
```ts
90+
const result = await repository.execute('MyCollection', 'aggregate', [
91+
{$unwind: '$data'},
92+
{$out: 'tempData'},
93+
]);
94+
```
95+
96+
Use parameterized queries whenever possible instead of constructing SQL strings
97+
manually.
98+
6699
See API docs for parameter reference, additional information and examples:
67100

68101
- [SQL variant](./apidocs/repository.defaultcrudrepository.execute.md)

0 commit comments

Comments
 (0)