⬇️ Support for multiple bundles in comic model

This commit is contained in:
2021-08-25 23:07:40 -07:00
parent f122515d6a
commit bf701d8838
2 changed files with 27 additions and 17 deletions

View File

@@ -46,7 +46,7 @@ const ComicSchema = mongoose.Schema({
acquisition: { acquisition: {
wanted: Boolean, wanted: Boolean,
release: {}, release: {},
directconnect: {}, directconnect: Array,
torrent: { torrent: {
sourceApplication: String, sourceApplication: String,
magnet: String, magnet: String,

View File

@@ -70,10 +70,10 @@ export default class ProductsService extends Service {
}; };
}> }>
) { ) {
console.log("ASDASD", ctx.params);
let volumeDetails; let volumeDetails;
const comicMetadata = ctx.params; const comicMetadata = ctx.params;
if (comicMetadata.sourcedMetadata.comicvine && if (
comicMetadata.sourcedMetadata.comicvine &&
!isNil( !isNil(
comicMetadata.sourcedMetadata.comicvine comicMetadata.sourcedMetadata.comicvine
.volume .volume
@@ -161,7 +161,8 @@ export default class ProductsService extends Service {
ctx: Context<{ ctx: Context<{
comicObjectId: string; comicObjectId: string;
resultId: string; resultId: string;
downloadResult: {}; bundleId: string;
directoryIds: [];
searchInstanceId: string; searchInstanceId: string;
}> }>
) { ) {
@@ -169,21 +170,30 @@ export default class ProductsService extends Service {
ctx.params.comicObjectId ctx.params.comicObjectId
); );
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
Comic.findByIdAndUpdate(comicObjectId, { Comic.findByIdAndUpdate(
acquisition: { comicObjectId,
directconnect: { {
resultId: ctx.params.resultId, $push: {
downloadResult: ctx.params.downloadResult, "acquisition.directconnect": {
searchInstanceId: ctx.params.searchInstanceId, resultId:
ctx.params.resultId,
bundleId: ctx.params.bundleId,
directoryIds: ctx.params.directoryIds,
searchInstanceId:
ctx.params
.searchInstanceId,
},
},
},
{ new: true, safe: true, upsert: true },
(err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
} }
} }
}, { new: true}, (err, result) =>{ );
if(err) {
reject(err);
} else {
resolve(result);
}
});
}); });
}, },
}, },