add some basic children counts

This commit is contained in:
sentriz
2019-06-07 17:29:57 +01:00
parent 188b52bc61
commit 266014da8b
5 changed files with 26 additions and 8 deletions

No files matched your search

+8 -1
View File
@@ -20,8 +20,15 @@ import (
func (c *Controller) GetIndexes(w http.ResponseWriter, r *http.Request) {
var folders []*model.Album
c.DB.
Where("parent_id = 1").
Select("*, count(sub.id) as child_count").
Joins(`
LEFT JOIN albums sub
ON albums.id = sub.parent_id
`).
Where("albums.parent_id = 1").
Group("albums.id").
Find(&folders)
indexMap := make(map[string]*subsonic.Index)
indexes := []*subsonic.Index{}