1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-02 00:38:14 +09:00
This commit is contained in:
syuilo 2017-03-19 00:02:40 +09:00
parent 895aeb12c6
commit 3046d3e7c0

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