mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-28 00:03:09 +02:00
[API] #158
This commit is contained in:
parent
895aeb12c6
commit
3046d3e7c0
1 changed files with 14 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
import * as mongo from 'mongodb';
|
||||
import DriveFolder from '../models/drive-folder';
|
||||
import DriveFile from '../models/drive-file';
|
||||
import deepcopy = require('deepcopy');
|
||||
|
||||
/**
|
||||
|
@ -37,6 +38,19 @@ const self = (
|
|||
_folder.id = _folder._id;
|
||||
delete _folder._id;
|
||||
|
||||
if (opts.detail) {
|
||||
const childFoldersCount = await DriveFolder.count({
|
||||
parent_id: _folder.id
|
||||
});
|
||||
|
||||
const childFilesCount = await DriveFile.count({
|
||||
folder_id: _folder.id
|
||||
});
|
||||
|
||||
_folder.folders_count = childFoldersCount;
|
||||
_folder.files_count = childFilesCount;
|
||||
}
|
||||
|
||||
if (opts.detail && _folder.parent_id) {
|
||||
// Populate parent folder
|
||||
_folder.parent = await self(_folder.parent_id, {
|
||||
|
|
Loading…
Reference in a new issue