feat: Trash (#1082)
* wip: trash * Enable restoration of deleted documents * update Trash icon * Add endpoint to trigger garbage collection * fix: account for drafts * fix: Archived documents should be deletable * fix: Missing delete cascade * bump: upgrade rich-markdown-editor
This commit is contained in:
@ -147,9 +147,11 @@ Document.associate = models => {
|
||||
});
|
||||
Document.hasMany(models.Backlink, {
|
||||
as: 'backlinks',
|
||||
onDelete: 'cascade',
|
||||
});
|
||||
Document.hasMany(models.Star, {
|
||||
as: 'starred',
|
||||
onDelete: 'cascade',
|
||||
});
|
||||
Document.hasMany(models.View, {
|
||||
as: 'views',
|
||||
@ -514,6 +516,10 @@ Document.prototype.unarchive = async function(userId) {
|
||||
await collection.addDocumentToStructure(this);
|
||||
this.collection = collection;
|
||||
|
||||
if (this.deletedAt) {
|
||||
await this.restore();
|
||||
}
|
||||
|
||||
this.archivedAt = null;
|
||||
this.lastModifiedById = userId;
|
||||
await this.save();
|
||||
|
Reference in New Issue
Block a user