mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
return items
This commit is contained in:
parent
bca40318bd
commit
f70c9ff53e
@ -28,6 +28,7 @@ export default {
|
|||||||
|
|
||||||
release.listLength = totalTracks
|
release.listLength = totalTracks
|
||||||
release.items = tracks
|
release.items = tracks
|
||||||
|
release.list = tracks
|
||||||
|
|
||||||
return release
|
return release
|
||||||
},
|
},
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
import { MusicRelease, Track } from "@db_models"
|
import { MusicRelease, Track } from "@db_models"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
middlewares: ["withAuthentication"],
|
middlewares: ["withAuthentication"],
|
||||||
fn: async (req) => {
|
fn: async (req) => {
|
||||||
const { keywords, limit = 10, offset = 0 } = req.query
|
const { keywords, limit = 10, offset = 0 } = req.query
|
||||||
|
|
||||||
const user_id = req.auth.session.user_id
|
const user_id = req.auth.session.user_id
|
||||||
|
|
||||||
let searchQuery = {
|
let searchQuery = {
|
||||||
user_id,
|
user_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keywords) {
|
if (keywords) {
|
||||||
searchQuery = {
|
searchQuery = {
|
||||||
...searchQuery,
|
...searchQuery,
|
||||||
title: {
|
title: {
|
||||||
$regex: keywords,
|
$regex: keywords,
|
||||||
$options: "i",
|
$options: "i",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let releases = await MusicRelease.find(searchQuery)
|
let releases = await MusicRelease.find(searchQuery)
|
||||||
.sort({ created_at: -1 })
|
.sort({ created_at: -1 })
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.skip(offset)
|
.skip(offset)
|
||||||
|
|
||||||
if (req.query.resolveItemsData === "true") {
|
if (req.query.resolveItemsData === "true") {
|
||||||
releases = await Promise.all(
|
releases = await Promise.all(
|
||||||
playlists.map(async playlist => {
|
playlists.map(async (playlist) => {
|
||||||
playlist.list = await Track.find({
|
playlist.items = await Track.find({
|
||||||
_id: [...playlist.list],
|
_id: [...playlist.list],
|
||||||
})
|
})
|
||||||
|
|
||||||
return playlist
|
return playlist
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
total_length: await MusicRelease.countDocuments(searchQuery),
|
total_length: await MusicRelease.countDocuments(searchQuery),
|
||||||
items: releases,
|
items: releases,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user