This commit is contained in:
syuilo 2017-03-19 00:02:40 +09:00
parent c062e45a0d
commit 0daa42ec0d

View File

@ -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, {