mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
Hello gridfs lib + fsHooks for mongodb bucket storage
This commit is contained in:
parent
d75fd69406
commit
18bd797ab9
5 changed files with 128 additions and 0 deletions
17
models/lib/fsHooks/createOnAfterRemove.js
Normal file
17
models/lib/fsHooks/createOnAfterRemove.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { createObjectId } from '../grid/createObjectId';
|
||||
|
||||
const createOnAfterRemove = bucket =>
|
||||
function onAfterRemove(files) {
|
||||
files.forEach(file => {
|
||||
Object.keys(file.versions).forEach(versionName => {
|
||||
const gridFsFileId = (file.versions[versionName].meta || {})
|
||||
.gridFsFileId;
|
||||
if (gridFsFileId) {
|
||||
const gfsId = createObjectId({ gridFsFileId });
|
||||
bucket.delete(gfsId, err => {
|
||||
// if (err) console.error(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue