์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- ๋ธ๋์น ์์ฑ
- ![rejected]
- markdown
- ์ฝ๋๋ธ๋ญ
- branch ์์ฑ
- ๋ธ๋์น ํ์ธ
- Git๋ช ๋ น์ด
- branch ์ญ์
- ์ฝ๋๋ธ๋ก
- branch ํ์ธ
- ๋งํฌ๋ค์ด
- ๋ธ๋์น ์ญ์
- Today
- Total
DevLog
[โ๏ธ Project Dev Log] 2022-01-08 ๋ณธ๋ฌธ
[โ๏ธ Dev Log] 2022-01-08
์ค๋์ ์ด๋ป๊ฒ ํ๋ก์ ํธ์ ๊ธฐ์ฌํ๋์?
- lounge ์ ์ฒด ์ ๋ณด ์กฐํ api๊ธฐ๋ฅ ๊ตฌํ
- lounge ํน์ ์ ๋ณด ์กฐํ api๊ธฐ๋ฅ ๊ตฌํ
- ๋๊ธ ์์ฑ, ์ ๊ณ ์์ฑ api๊ธฐ๋ฅ ๊ตฌํ
์ค๋์ ํ๋ก์ ํธ์์ ํ๋ ์ ์ ๋ฌด์์ธ๊ฐ์?
sequelize์์ ์ํ๋ ๋ฐ์ดํฐ๋ง ์ถ์ถ
์์ฑํ ๋๊ธ์ ๋ถ๋ฌ์์ฃผ๋ ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ์ค
ํ ๊ณณ์ ๊ธ์ ์์ฑ๋ ๋ค์์ ๋๊ธ๋ค์ ํ๋ฒ์ ๊ฐ์ ธ์ ์ค์ผ ํ๋๋ฐ ์ด ๋ถ๋ถ์์ ์๊ธด ๋ฌธ์ ๊ฐ
๋ด๊ฐ ํ์ํ ์ ๋ณด๋ dataValues๊ฐ๋ค๋ง ํ์ํ์๋๋ฐ
[
comment {
dataValues: {
userId: 3,
contents: '๋๊ธ 1',
rating: 2,
createdAt: 2022-01-08T13:01:29.000Z
},
_previousDataValues: {
userId: 3,
contents: '๋๊ธ 1',
rating: 2,
createdAt: 2022-01-08T13:01:29.000Z
},
uniqno: 1,
_changed: Set(0) {},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [Array]
},
isNewRecord: false
},
comment {
dataValues: {
userId: 3,
contents: '๋๊ธ 2',
rating: 2,
createdAt: 2022-01-08T13:01:40.000Z
},
_previousDataValues: {
userId: 3,
contents: '๋๊ธ 2',
rating: 2,
createdAt: 2022-01-08T13:01:40.000Z
},
uniqno: 1,
_changed: Set(0) {},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [Array]
},
isNewRecord: false
},
comment {
dataValues: {
userId: 3,
contents: '๋๊ธ 3',
rating: 2,
createdAt: 2022-01-08T13:05:33.000Z
},
_previousDataValues: {
userId: 3,
contents: '๋๊ธ 3',
rating: 2,
createdAt: 2022-01-08T13:05:33.000Z
},
uniqno: 1,
_changed: Set(0) {},
_options: {
isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
raw: true,
attributes: [Array]
},
isNewRecord: false
},
]
sequelize์์ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๋ฉด dataValues ๋ฐ์ดํฐ ๋ฟ๋ง ์๋๋ผ ์ด์ ๋ฐ์ดํฐ ๊ฐ๊ณผ ๋ฐ์ดํฐ์ ๊ด๋ จํ ์ฌ๋ฌ ์ต์ ๊ฐ๋ค์ ์ ๋ถ ๋ณด์ฌ์ฃผ๋ ๊ฒ ๋ฌธ์ ์๋ค, ๋ด๊ฐ ์ํ๋ ์ ๋ณด๋ง ์ถ์ถํ๋ ค๋ฉด ๋ฐ๋ก ํ์ฒ๋ฆฌ๋ฅผ ํด์ค์ผ ํ๋ค.
๋ฌด์จ ๋ฉ์๋๋ฅผ ์ฌ์ฉํด์ ์ฒ๋ฆฌ๋ฅผ ํด์ค๊น ๊ณ ๋ฏผํ๋ค๊ฐ ์ ์ ๋ฐฐ์ ๋ javascirpt method ์ค์ filter, map, reduce ์ผ์ด์ฌ ๋ฉ์๋๊ฐ ์๊ฐ์ด ๋ฌ๋ค.
๊ทธ ์ค ๋ฐฐ์ด ๋ด์ ์์๋ฅผ ์ฃผ์ด์ง ํจ์์ ํธ์ถํ๊ณ ๊ทธ ๊ฒฐ๊ณผ๋ค์ ๋ชจ์ ์๋ก์ด ๋ฐฐ์ด์ ๋ด์ ๋ฐํํด์ฃผ๋ map์ ์ฐ๋ ๊ฒ์ด ์ข๊ฒ ๋ค๊ณ ์๊ฐํด์ map์ ์ฌ์ฉํด์ ์ฝ๋๋ฅผ ์์ฑํด ๋ณด์๋ค.
const newData = data.map((element) => element.dataValues);
๋จ์ํ๊ฒ ๊ธฐ๋ณธ์ ์ธ map ๋ฉ์๋๋ง์ ์ด์ฉํด์ ํํฐ๋ง ํ๋๋ ๊ฒฐ๊ณผ ๊ฐ์ด ์ ํ์ฒ๋ฆฌ ๋์ด ์ถ๋ ฅ๋์๋ค.
[
{
userId: 3,
contents: '๋๊ธ 1',
rating: 2,
createdAt: 2022-01-08T13:28:44.000Z
},
{
userId: 3,
contents: '๋๊ธ 2',
rating: 2,
createdAt: 2022-01-08T13:28:55.000Z
},
{
userId: 3,
contents: '๋๊ธ 3',
rating: 2,
createdAt: 2022-01-08T13:29:50.000Z
}
]
๋ด์ผ์ ํ๋ก์ ํธ์ ๊ธฐ์ฌํ๊ธฐ ์ํด ๋ฌด์์ ํด์ผ ํ๋์?
- ์นด์นด์ค oauth ์์ ๋ก๊ทธ์ธ api ๊ธฐ๋ฅ ๊ตฌํ
- aws๋ฐฐํฌ
'๐ Project - Dev Log' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[โ๏ธ Project Dev Log] 2022-01-11 (0) | 2022.01.11 |
---|---|
[โ๏ธ Project Dev Log] 2022-01-10 (0) | 2022.01.10 |
[โ๏ธ Project Dev Log] 2022-01-07 (0) | 2022.01.08 |
[โ๏ธ Project Dev Log] 2022-01-06 (0) | 2022.01.06 |
[โ๏ธ Project Dev Log] 2022-01-05 (0) | 2022.01.06 |