sqlWith + display: calendar 이용시 안내
sqlWith에서 moment를 쓰거나 responseFn에서 date 변환할 수 있습니다.
1번: sqlWith에서 moment 사용
sqlWith:
- name: p2
resource: mysql.qa
query: >
SELECT * FROM wine_stock WHERE deleted_at IS NOT NULL
sqlType: select
sql: >
SELECT moment(deleted_at).format('YYYY-MM-DD') as date, name as name FROM p2
params:
- key: calendar
range: true
valueFromCalendar: true
display: calendar
autoload: true
# cache: true
columns:
name:
label: 일시품절기간
2번: responseFn에서 date 변환
sqlWith:
- name: p2
resource: mysql.qa
query: >
SELECT * FROM wine_stock WHERE deleted_at IS NOT NULL
sql: >
SELECT deleted_at as date, name as name FROM p2
params:
- key: calendar
range: true
valueFromCalendar: true
display: calendar
autoload: true
# cache: true
columns:
name:
label: 일시품절기간
responseFn: |
rows = rows.map(e => {
e.date = moment(e.date).format('YYYY-MM-DD')
return e
})
console.log(rows)
return rows