Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { db } from "../../db/postgre.js";
|
||||
import { DriveFolders, DriveFiles } from "../index.js";
|
||||
import { DriveFolder } from "../entities/drive-folder.js";
|
||||
import { awaitAll } from "../../prelude/await-all.js";
|
||||
export const DriveFolderRepository = db.getRepository(DriveFolder).extend({
|
||||
async pack (src, options) {
|
||||
const opts = Object.assign({
|
||||
detail: false
|
||||
}, options);
|
||||
const folder = typeof src === "object" ? src : await this.findOneByOrFail({
|
||||
id: src
|
||||
});
|
||||
return await awaitAll({
|
||||
id: folder.id,
|
||||
createdAt: folder.createdAt.toISOString(),
|
||||
name: folder.name,
|
||||
parentId: folder.parentId,
|
||||
...opts.detail ? {
|
||||
foldersCount: DriveFolders.countBy({
|
||||
parentId: folder.id
|
||||
}),
|
||||
filesCount: DriveFiles.countBy({
|
||||
folderId: folder.id
|
||||
}),
|
||||
...folder.parentId ? {
|
||||
parent: this.pack(folder.parentId, {
|
||||
detail: true
|
||||
})
|
||||
} : {}
|
||||
} : {}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user