firestore ã® SDK ã« withConverter ã¨ããã¡ã½ãããããã®ã§ããããã®å®£ä¼ã§ãã åã欲ããã£ã¦ã©ããããã¨ï¼ ãã¨ãã° firestore ä¸ã®ããããã¥ã¡ã³ãã name 㨠age ã¨ãããã£ã¼ã«ããæã£ã¦ããã¨ãã¦ããããã¯ã©ã¤ã¢ã³ããåå¾ããã¨ããã®ãã¼ã¿ã« name 㨠age ãåå¨ããä¿è¨¼ã¯ããã®ã§ããããã db.collection("user") .withConverter(converter) .get() .then(result => { const data = result.docs.map(d => ({ // æ¬å½ã«nameãããï¼ name: d.data().name, // æ¬å½ã«ageãããï¼ age: d.data().age, })) setState(data) }) d.data() ã¯ã¯ã©ã¤ã¢ã³ãããªãã¼ã·
ã¯ããã« Firebase Realtime DBãå®è·µæå ¥ããã«ããã£ã¦èãããã¨ãèªãã§é ãã¦ãããã¨ããããã¾ãããå¤ãã®æ¹ããããããããé ãã¦ãä»åã®ãã®è¨äºãæ¸ãã¢ããã¼ã·ã§ã³ã«ãªãã¾ãã:bow_tone1: æ¬å½ã«ãããã¨ããããã¾ããï¼ ãã¦ãCloudFirestoreã¯ãFirebase Realtime Databaseã¨ã¯å ¨ãéããã¼ã¿ãã¼ã¹ã§ããç¹ã«SubCollectionãQueryãå°å ¥ããããã¨ã«ããããªã¬ã¼ã·ã§ã³ã·ããã®è¨è¨ã«é¢ãã¦å¤§ããç°ãªãã¾ãã ãã®è¨äºã§ã¯ã主ã«CloudFirestoreã«ããããªã¬ã¼ã·ã§ã³ã·ããã®è¨è¨æ¹æ³ãããã¢ããªã»CloudFunctionsã«è³ãã¾ã§ãå¹ åºã解説ãã¦è¡ããã¨æãã¾ãã 次ã®è¨äºã§ã¯ãã¼ã¿ãã¼ã¹ã®æ´å²ã解説ãã¦ãã¾ãã RDBã®éçã¨NoSQLã®ç»å ´ Cloud Firestoreã§ã®éçºã«ã¤ã㦠ç§ã®çµ
ããã¯ä½ Firebase(å ·ä½çã«ã¯ãCloud Firestore)ã®éç¨ã«ä¾¿å©ãªfsrpl (Firestore Replication Tool) ã¨ããã®ä½¿ãæ¹ã«ã¤ãã¦ç´¹ä»ãã¾ãã以åãå¥ã®å ´æã«æ稿ãããã®ãããã¾ããããã®CLIãã¼ã«ã«ãªãã·ã§ã³å¤æ´ã®ãã£ãããæ¬è¨äºã§ã¯ææ°ã®å©ç¨æ¹æ³ã«ã¤ãã¦ã¦ã¼ã¹ã±ã¼ã¹ãæ·»ãã¦ç´¹ä»ãã¾ãã fsrplã®æ¦è¦ FirebaseOpenSourceã§ãç´¹ä»ããã¦ããCLIãã¼ã«ã§ãä¸è¨ã®ï¼ã¤ã®æ©è½ãããã¾ãã(READMEããã®æç²ã§ã) copy ç¹å®ã®ããã¥ã¡ã³ãããå¥ã®Collectioné ä¸ã«ã³ãã¼ã§ãããã¾ããã¯ã¤ã«ãã«ã¼ããå©ç¨ãããã¨ã§ã³ã¬ã¯ã·ã§ã³é ä¸ã®ãã¹ã¦ã®ããã¥ã¡ã³ããã³ãã¼ã§ããã ããã«ãç¹å®ã®Projectã®Firebaseããä»ã®Firebaseã¸ãç¹å®ã®ããã¥ã¡ã³ãã®ãã¼ã¿ãã³ãã¼ã§ãã dump ç¹å®ã®ããã¥ã¡ã³
Firestoreã§åè¦ç´ ã®æ°ãã«ã¦ã³ãããæ¹æ³ãç´¹ä»ãã¾ããSQLæã§è¨ãã¨ããã®ãCOUNT()æã§ã¬ã³ã¼ã件æ°ãåå¾ããæ¹æ³ã®ãFirestoreã§ã®ããæ¹ã§ãã ç°¡åãªä»¶æ°ã®åå¾æ¹æ³ããã件æ°ãè¨å¤§ã«ãªãã³ã¬ã¯ã·ã§ã³ã®å¹ççãªã«ã¦ã³ãæ¹æ³ã«ã¤ãã¦ãç´¹ä»ãã¦ããã¾ãã ã¹ãã³ãµã¼ãªã³ã¯ 100件ç¨åº¦ã®å°ããã³ã¬ã¯ã·ã§ã³ã®ã«ã¦ã³ãæ¹æ³ ã³ã¬ã¯ã·ã§ã³ã®æ°ã100件ç¨åº¦ã®å ´åã¯ãã¯ã©ã¤ã¢ã³ããµã¤ãã§ã«ã¦ã³ãããã®ã楽ã§ãã以ä¸ã®ãµã³ãã«ã³ã¼ãã¯ãusersã³ã¬ã¯ã·ã§ã³ãåå¾ãsizeããããã£ã§è¦ç´ ã®æ°ãåå¾ãã¦ãã¾ãã db.collection('users').get().then(snap => { size = snap.size // will return the collection size }); usersã³ã¬ã¯ã·ã§ã³ã®å ¨ãã¼ã¿ãã¯ã©ã¤ã¢ã³ãå´ã§ãã¦ã³ãã¼ãããè¦ç´ æ°
Cloud Firestoreã«ããã¯ã¢ããã®ä»çµã¿ãç¡ããã¨ã¯ä»¥åããã®èª²é¡ã§ãããããããã gcloud ã³ãã³ãã¨ãã¦importã»exportãæä¾ããã¾ããð (Cloud Next 2018 ã§ãã¢ãã¦ã³ã¹ããã£ãããã§ããã以ä¸ã®è¨äºã§ç¥ãã¾ããã)
追è¨: v2ã«ã¤ãã¦ã®ã¨ã³ããªã¯ãã¡ã Firebaseã®æ°ããDBã§ããFirestoreã¯ä½¿ã£ã¦ããã§ããããï¼ ä»ã¾ã§ã¯ã©ããã¦ããµã¼ãã¼å´ã®å®è£ ãå¿ è¦ã ã£ãDBã¸ã®ãã¼ã¿ã®æ ¼ç´ãã¯ã©ã¤ã¢ã³ãã ãã§æ¸ãããã«ãªã£ãã®ã§å§åçã«ä¾¿å©ã§ããã ãããªããã§èªåãjsããFirestoreã使ãæ©ä¼ãå¢ãã¦ããã®ã§ãããæ¯åæ¸ããã³ã«APIãå¾®å¦ã«ä½¿ãã¥ããã¨æãã¦ãã¾ãããããã§ãFirestoreãããæãã«æ±ããfirestore-simpleã¨ããã©ã¤ãã©ãªããªãªã¼ã¹ãã¾ããã npm: https://www.npmjs.com/package/firestore-simple GitHub: https://github.com/Kesin11/Firestore-simple ãµã³ãã«ã³ã¼ã ã¾ããæ¯è¼ã®ããã«Firestoreãç´ ã§ä½¿ã£ãå ´åã®ã³ã¼ãã§ãã const ad
[2019å¹´10æ追è¨] Firebase Extensions ã® Export Collections to BigQueryãç»å ´2019å¹´9æã« Firebase Extensions ãç»å ´ããããã«å«ã¾ããExport Collections to BigQuery ãããã»ã¼ä¸ä½äºæãã¤ãæ軽ã§ãã æ¬è¨äºã®ããæ¹ã®ãããªä¸æ¬ã¨ã¯ã¹ãã¼ãå½¢å¼ã§ã¯ãªããFirestore ã®ãã¼ã¿å¤æ´ããªã¢ã«ã¿ã¤ã ã§èç©ããã¦ããBigQueryã®viewæ©è½ã§ç¾æç¹ã®ç¶æ ã«å¯¾ãã¦åæã§ããä½ãã«ãªã£ã¦ãã¾ããã¾ã£ããåããã®ã§ã¯ãªããããç´°ãã使ãåæãã³ã¹ãé¢ãªã©ã§å·®ç°ã¯ããã¾ãã
ããã¯ï¼ Firebase Meetup #10 㧠ãFirestoreå°å ¥åã«æ¤è¨ãããã£ããã¹ãï¼ã ã¨ãããã¼ãã§çºè¡¨ããã¢ã¼ããã¯ãã£é¨åã®è©±ãã®3ã â Firestoreãä¸å¿ã«æ®ããå ¨ä½è¨è¨ã®ã³ã³ã»ãã â¡PubSubã¨Cloud Functionsã使ã£ã¦ãFirestoreã®Collectionããã¤ã¯ããµã¼ãã¹ã«è¦ç«ã¦ã話 â¢ããã©ã¼ãã³ã¹ã®å£å対çã¨ãã¦ãCacheã®Collectionãä½ã£ã話 âä»å ãã©ã¤ããã㨠ã¾ããã©ããªãã©ã¤ãããã®ã説æãã¦ããã¾ãã ãã®ä¸ã§ãä»åã話ããã®ãã赤丸ãããé¨åã§ãã èæ¯ ã¼ããã¯ãé大ãªåé¡ãæ±ãã¦ãã¾ããã 社å ã®äººãã¦ã¼ã¶ã¼ã§ããã¢ããªã±ã¼ã·ã§ã³ãªã®ã§çãã¦ããçµæãããã©ã¼ãã³ã¹ãåçã«æªããªã£ã¦ããã®ã§ããã (ã¼ããã¨ãããã¼ãã ãã®ãã...) ç¶æ³ã¨ãã¦ã¯ã å ã ãéç¨ãã¡ããã¨æçã«ã·ã³ãã«ã«ãã¦ã
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}