|
@@ -108,16 +108,22 @@ module.exports = function(crowi) {
|
|
|
attachmentSchema.statics.removeAttachmentsByPageId = function(pageId) {
|
|
attachmentSchema.statics.removeAttachmentsByPageId = function(pageId) {
|
|
|
var Attachment = this;
|
|
var Attachment = this;
|
|
|
|
|
|
|
|
- // todo
|
|
|
|
|
- return Promise.resolve();
|
|
|
|
|
- //return new Promise(function(resolve, reject) {
|
|
|
|
|
- // // target find
|
|
|
|
|
- // Attachment.getListByPageId(pageId)
|
|
|
|
|
- // .then(function(attachments) {
|
|
|
|
|
- // }).then(function(done) {
|
|
|
|
|
- // }).catch(function(err) {
|
|
|
|
|
- // });
|
|
|
|
|
- //});
|
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
|
+ Attachment.getListByPageId(pageId)
|
|
|
|
|
+ .then((attachments) => {
|
|
|
|
|
+ for (attachment of attachments) {
|
|
|
|
|
+ Attachment.removeAttachment(attachment).then((res) => {
|
|
|
|
|
+ // do nothing
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ debug('Attachment remove error', err);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ resolve(attachments);
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ reject(err);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|