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