。。。。。。
老师代码不报错最后查询出来的是个空的数组是怎么回事
老师代码不报错最后查询出来的是个空的数组是怎么回事
2020-09-24
==============service=================
static async getContentList(){
const movieList = await MovieDao.getMovieList()
const musicList = await MusicDao.getMusicList()
const sentenceList = await SentenceDao.getSentenceList()
// 打印一下这三个结果
console.log(movieList)
console.log(musicList)
console.log(sentenceList)
=================v1============
contentApi.get('/',async ctx => {
const contentList = await ContentService.getContentList()
ctx.json(contentList)
})
===========(dao) movie===
static async getMovieList(){
return await MovieModel.findAll()
}
==========(dao) music=====
static async getMusicList(){
const res = await MusicModel.findAll()
return res
}
===========(dao) sentence=======
static async getSentenceList(){
const res = await SentenceModel.findAll()
return res
}
==============service=================
static async getContentList(){
const movieList = await MovieDao.getMovieList()
const musicList = await MusicDao.getMusicList()
const sentenceList = await SentenceDao.getSentenceList()
let res= []
res.push.apply(res,movieList)
res.push.apply(res,musicList)
res.push.apply(res,sentenceList)
res.sort((a,b) => b.created_at.localeCompare(a.created_at))
return res
}
举报