-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdailyDao.js
34 lines (31 loc) · 864 Bytes
/
dailyDao.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Sequelize } from 'sequelize'
import dayjs from 'dayjs'
const sequelize = new Sequelize(
process.env.YOUDB_NAME || 'youtubedb',
process.env.YOUDB_USER || 'devuser',
process.env.YOUDB_PASS || 'devpass',
{
host: 'localhost',
dialect: 'mariadb',
timezone: 'Asia/Seoul',
logging: true,
}
)
async function newList(date) {
const dddd = dayjs(date).format('YYYY-MM-DD hh')
const list = await sequelize.query(
`select y.title, y.videoId, y.thumbnail, y.publishedAt,
c.title ctitle, c.thumbnail cthumbnail, c.category
from Videos y
join Channels c on c.id = y.ChannelId and c.lang = 'ko' and c.category in ('dev', 'food')
where y.publishedAt > $date order by y.publishedAt desc;`,
{
bind: { date: dddd },
type: sequelize.QueryTypes.SELECT,
}
)
return list
}
export default {
newList,
}