Improve file box api - add delete endpoints, categories
This commit is contained in:
@@ -3,6 +3,10 @@ const uuid = require('uuid').v4
|
||||
const { ObjectId } = require('mongodb')
|
||||
|
||||
class FileBoxModel extends Model {
|
||||
static get services() {
|
||||
return [...super.services, 'models']
|
||||
}
|
||||
|
||||
static get schema() {
|
||||
return {
|
||||
UUID: { type: String, default: uuid },
|
||||
@@ -29,6 +33,13 @@ class FileBoxModel extends Model {
|
||||
})
|
||||
}
|
||||
|
||||
async children() {
|
||||
return this.constructor.find({
|
||||
parentUUID: this.UUID,
|
||||
active: true,
|
||||
})
|
||||
}
|
||||
|
||||
async files() {
|
||||
const File = this.models.get('upload::File')
|
||||
return await File.find({
|
||||
@@ -40,8 +51,10 @@ class FileBoxModel extends Model {
|
||||
|
||||
async to_api() {
|
||||
return {
|
||||
type: 'folder',
|
||||
UUID: this.UUID,
|
||||
name: this.name,
|
||||
title: this.name,
|
||||
pageId: this.pageId,
|
||||
parentUUID: this.parentUUID,
|
||||
rootUUID: this.rootUUID,
|
||||
|
||||
Reference in New Issue
Block a user