docs: add documentation for .orIgnore method (#10607)

This commit is contained in:
Alessio Napolitano 2024-01-26 07:18:18 +01:00 committed by GitHub
parent 99d8249e45
commit 032f5350e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,6 +57,24 @@ await dataSource
.execute()
```
### IGNORE error (MySQL) or DO NOTHING (Postgres) during insert
If the values you are trying to insert conflict due to existing data or containing invalid data, the `orIgnore` function can be used to suppress errors and insert only rows that contain valid data.
```typescript
await dataSource
.createQueryBuilder()
.insert()
.into(User)
.values({
firstName: "Timber",
lastName: "Saw",
externalId: "abc123",
})
.orIgnore()
.execute()
```
### Skip data update if values have not changed (Postgres)
```typescript