[Firebase๐Ÿ”ฅ] ํŒŒ์ด์–ด์Šคํ† ์–ด์— jsonํŒŒ์ผ ์—…๋กœ๋“œํ•˜๊ธฐ - uploading massive json data to firestore with script

Inaยท2021๋…„ 10์›” 12์ผ
2

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
16/20
post-custom-banner

https://www.youtube.com/watch?v=Qg2_VFFcAI8
์œ„ ์˜์ƒ์—์„œ ์ œ๊ณตํ•˜๋Š” uploader.jsํŒŒ์ผ๋งŒ ์žˆ์œผ๋ฉด ๋œ๋‹ค. ๊ทธ๋ƒฅ ํผ์˜ฌ๊นŒํ•˜๋‹ค๊ฐ€ ์–‘์‹ฌ์ด ์ฐ”๋ ค์„œ ๋งํฌ๋กœ ๋‚จ๊ธด๋‹ค.
์•„, firebase-admin์€ ์„ธํŒ…์ด ๋˜์–ด์žˆ์–ด์•ผ ํ•œ๋‹ค. ๋‚˜๋Š” functions ์จ๋ณธ๋‹ค๊ณ  ์„ธํŒ…ํ•ด๋‘์—ˆ๋˜ํ„ฐ๋ผ ๊ทธ๋ƒฅ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค! ์ด๋“!

์•„๋งˆ ์œ„ ์˜์ƒ์—์„œ ์ œ๊ณตํ•˜๋Š” uploader.js ํŒŒ์ผ์„ ๊ทธ๋ƒฅ ์‚ฌ์šฉํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋‚  ์ˆ˜ ์žˆ๋‹ค.

 throw new Error(`${validate_1.invalidArgumentMessage(arg, 'resource path')} Path must be a non-empty string.`);
        ^

Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string.

document ID ์ƒ์„ฑํ•  ๋•Œ Json object์˜ itemID๋ฅผ ๊ฐ€์ ธ์™€์„œ ์•„์ด๋””๊นŒ์ง€ ๋ฐ•์•„์„œ firestore์— ์—…๋กœ๋“œํ•˜๋ฉด์„œ ์ƒ๊ธฐ๋Š” ์˜ค๋ฅ˜๋‹ค.

ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์€ uploader.js 25๋ฒˆ์งธ ๋ผ์ธ์˜ doc(obj.itemID)๋ฅผ โžก๏ธ doc()์œผ๋กœ ๋ฐ”๊พธ๋ฉด ๋œ๋‹ค. ๋Œ€์‹  ์ง€์ •๋œ ID๊ฐ’์„ ๋ฐ•์•„์„œ ์ €์žฅ์‹œํ‚ค์ง„ ๋ชป ํ•˜๊ณ  firestore์—์„œ ๋žœ๋คํ•˜๊ฒŒ ์•„์ด๋””๋ฅผ ์ƒ์„ฑํ•ด์ค€๋‹ค.

profile
ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž. ๊ธฐ๋กํ•˜๊ธฐ, ์š”๊ฐ€, ๋“ฑ์‚ฐ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€