ソースを参照

fix: bulk add artists/genres/tags had a few issues

Kristian Vos 2 年 前
コミット
33a92f9243
1 ファイル変更3 行追加33 行削除
  1. 3 33
      backend/logic/actions/songs.js

+ 3 - 33
backend/logic/actions/songs.js

@@ -1892,17 +1892,7 @@ export default {
 				(songsFound, next) => {
 					const query = {};
 					if (method === "add") {
-						songModel.updateMany(
-							{ _id: { $in: songsFound } },
-							{ $pullAll: { genres } },
-							{ runValidators: true },
-							err => {
-								if (err) {
-									next(err);
-								}
-							}
-						);
-						query.$push = { genres: { $each: genres } };
+						query.$addToSet = { genres: { $each: genres } };
 					} else if (method === "remove") {
 						query.$pullAll = { genres };
 					} else if (method === "replace") {
@@ -2000,17 +1990,7 @@ export default {
 				(songsFound, next) => {
 					const query = {};
 					if (method === "add") {
-						songModel.updateMany(
-							{ _id: { $in: songsFound } },
-							{ $pullAll: { artists } },
-							{ runValidators: true },
-							err => {
-								if (err) {
-									next(err);
-								}
-							}
-						);
-						query.$push = { artists: { $each: artists } };
+						query.$addToSet = { artists: { $each: artists } };
 					} else if (method === "remove") {
 						query.$pullAll = { artists };
 					} else if (method === "replace") {
@@ -2108,17 +2088,7 @@ export default {
 				(songsFound, next) => {
 					const query = {};
 					if (method === "add") {
-						songModel.updateMany(
-							{ _id: { $in: songsFound } },
-							{ $pullAll: { tags } },
-							{ runValidators: true },
-							err => {
-								if (err) {
-									next(err);
-								}
-							}
-						);
-						query.$push = { tags: { $each: tags } };
+						query.$addToSet = { tags: { $each: tags } };
 					} else if (method === "remove") {
 						query.$pullAll = { tags };
 					} else if (method === "replace") {