浏览代码

Tried to fix weird issue with subdocuments in station documents

Kristian Vos 4 年之前
父节点
当前提交
df5726bf67
共有 3 个文件被更改,包括 3 次插入2 次删除
  1. 1 0
      backend/logic/db/schemas/playlist.js
  2. 0 1
      backend/logic/songs.js
  3. 2 1
      backend/logic/stations.js

+ 1 - 0
backend/logic/db/schemas/playlist.js

@@ -3,6 +3,7 @@ export default {
 	isUserModifiable: { type: Boolean, default: true, required: true },
 	songs: [
 		{
+			_id: { required: false },
 			songId: { type: String },
 			title: { type: String },
 			duration: { type: Number },

+ 0 - 1
backend/logic/songs.js

@@ -114,7 +114,6 @@ class _SongsModule extends CoreClass {
 			async.waterfall(
 				[
 					next => {
-						console.log(payload);
 						if (!mongoose.Types.ObjectId.isValid(payload.id)) return next("Id is not a valid ObjectId.");
 						return CacheModule.runJob("HGET", { table: "songs", key: payload.id }, this)
 							.then(song => next(null, song))

+ 2 - 1
backend/logic/stations.js

@@ -1,4 +1,5 @@
 import async from "async";
+import mongoose from "mongoose";
 
 import CoreClass from "../core";
 
@@ -747,7 +748,7 @@ class _StationsModule extends CoreClass {
 											return next(null, currentSong, currentSongIndex, station);
 										};
 
-										if (playlist[currentSongIndex]._id)
+										if (mongoose.Types.ObjectId.isValid(playlist[currentSongIndex]._id))
 											return SongsModule.runJob(
 												"GET_SONG",
 												{