docs: general fixes and overall changes (#7258)

* editing halfway

* edited second half

* adjust starter steps

* fix build

* typo fix
This commit is contained in:
Shahed Nasser
2024-05-07 18:00:28 +02:00
committed by GitHub
parent 8db62827ac
commit 327e446974
57 changed files with 872 additions and 1849 deletions
@@ -19,13 +19,13 @@ Refer to MikroORM's documentation for more details related to your use case.
## Relations Between Data Models
You can build relations between data models in the same module.
You can build relations between data models in the same module using foreign keys.
Refer to [MikroORM's relations definition](https://mikro-orm.io/docs/relationships)
Refer to [MikroORM's relations definitions](https://mikro-orm.io/docs/relationships) for more details.
<Note>
For building relationships between data models in different module, refer to the [Module Relationships chapter](../../modules/module-relationships/page.mdx) instead.
For building relationships between data models in different modules, refer to the [Module Relationships chapter](../../modules/module-relationships/page.mdx) instead.
</Note>
@@ -61,7 +61,7 @@ const VariantIdIndex = createPsqlIndexStatementHelper({
columns: "variant_id",
}).MikroORMIndex
@Entity({ tableName: "product_media" })
@Entity()
export default class ProductMedia {
@PrimaryKey({ columnType: "text" })
id: string
@@ -92,6 +92,11 @@ export default class ProductMedia {
onCreate() {
this.id = generateEntityId(this.id, "promed")
}
@OnInit()
OnInit() {
this.id = generateEntityId(this.id, "promed")
}
}
```
@@ -48,10 +48,12 @@ export default class MySoftDeletable {
---
## Managing Soft-Deletable Models
## Manage Soft-Deletable Models
Services extending the service factory have methods to soft delete and restore records for all models specified during its creation.
### Soft Delete a Record
For example, to soft delete a `MySoftDeletable` record:
```ts
@@ -62,6 +64,25 @@ await helloModuleService.softDelete([
The method receives an array of IDs of records to delete.
### Retrieve Soft-Deleted Records
The `retrieve`, `list`, and `listAndCount` methods accept as a second parameter a configuration object.
To retrieve soft-deleted records, set `withDeleted` to `true` in the configuration object passed as a second parameter.
For example:
```ts
const deletedRecords = await helloModuleService
.listMySoftDeletables({
// ...
}, {
withDeleted: true
})
```
### Restore a Soft-Deleted Record
To restore a `MySoftDeletable` record:
```ts
@@ -72,4 +93,4 @@ await helloModuleService.restore([
The method also receives an array of IDs of records to restore.
If the data model isn't the main data model, its method names are `softDelete` and `restore` suffixed with the plural name of the model. For example, `softDeleteMySoftDeletable`.
If the data model isn't the main data model, its method names are `softDelete` and `restore` suffixed with the plural name of the model. For example, `softDeleteMySoftDeletable`.