added sort to album service

parent f62cd5a1
......@@ -15,7 +15,7 @@ app.use(json());
app.use(cors());
app.use(urlencoded({extended: true}));
app.use(express.static('images'));
app.use(express.static('uploads'));
app.use('/artists', ArtistRouter);
app.use('/albums', AlbumRouter);
app.use('/tracks', TrackRouter);
......
......@@ -11,7 +11,9 @@ export const AlbumService = {
}).save();
},
get: async (id?: string) => {
return await AlbumModel.find(id ? {artist: id} : {}).populate('artist');
return await AlbumModel.find(id ? {artist: id} : {})
.populate('artist')
.sort({year: 1});
},
getById: async (id: string) => {
return await AlbumModel.findById(id).populate('artist');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment