March 2020
Intermediate to advanced
392 pages
10h 10m
English
Deleting a model works – very similar to update and create – like this:
user.delete(on: request.db) // returns EventLoopFuture<Void>
Vapor differentiates between a hard and a soft delete. A hard delete means the entry is deleted from the database. A soft delete only marks an entry as deleted – which says it can be restored.
To enable soft deletes, you have to specify the key to the variable/column in the model like this:
final class MyModel: Model { // ... @Field(key: "deletedAt") var deletedAt: Date?}
Read now
Unlock full access