ããã«ã¡ã¯ãKomercoã®é«æ©ã§ãã
Komercoããªãªã¼ã¹ããã¦ãããããã3å¹´ãçµã¨ãã¨ãã¦ãã¾ãã ã¯ãã¯ãããã®æ°è¦äºæ¥ãKomercoãã§ã¯ããã¯ã¨ã³ãã®ã»ã¼å ¨ã¦ãFirebaseã§éç¨ãã¦ãã¾ãã æ°è¦äºæ¥ã®ããã¨ã³ã¸ãã¢ã®æ°ã¯ã¾ã å°ãªããã®ã®ãFirebaseã®ãããã§ã¨ã³ã¸ãã¢ã¯ãµã¼ãã¹éçºã«å°å¿µã§ãã¦ããç¶æ³ã§ãæ¨å¹´ã¯Webçã®ãªãªã¼ã¹ãéæç¡æã¤ãã³ãããããã¦ã¼ã¶æ°ãããã«å¢å ãã¦ãã¦ãã¾ãã
ããã¾ã§å¤ãã®æ©è½ãéçºãã¦ãã¾ãããããã®ä¸ã§Firebaseãããæå¹ã«ä½¿ãããã試è¡é¯èª¤ãã¦ãã¾ããã ããããFirebaseã使ãããèãã¦ãã人ã«ããä»ç¾å¨Firebaseã使ã£ã¦ãã人ã«ãåèã«ãªããããKomercoã§å¾ãç¥è¦ãæ¸ãã¦ãããã¨æãã¾ãã
åå¾ç·¨ã¨ãªã£ã¦ãããååã¯Firestoreã®è¨è¨ã«ã¤ãã¦ã話ãããã¨æãã¾ãã
å½ããåã®æ©è½ã ãã©Firestoreã ã¨å®ç¾ãã«ãããã®
Komercoã¯å¨ãæçéå ·ãé£æã調å³æãæ±ãECãµã¼ãã¹ã§ãã ãã®ããFirestoreã«ã¯ãã¦ã¼ã¶ããååããã·ã§ããããªã©ã®ã³ã¬ã¯ã·ã§ã³ãåå¨ãã主ã«ããããæä½ããªããè²·ãç©ã®æ©è½ãå®ç¾ãã¦ãã¾ãã ã¾ããã¦ã¼ã¶ã¨ã·ã§ãããããåããè¡ãã¡ãã»ã¼ã¸æ©è½ããKomercoããã®ãç¥ããæ©è½ãªã©ããµã¼ãã¹ã¨ãã¦æ¨æºçãªæ©è½ãFirestoreã§å®ç¾ãã¦ãã¾ãã
éçºãç¶ããä¸ã§æ°ã¥ããã®ã¯ãä¸è¬çãªãµã¼ãã¹ã§ããè¦ãæ©è½ã§ããFirestoreã§å®ç¾ãã«ã¯ã²ã¨å·¥å¤«å¿ è¦ãªãã¨ããããã¨ã§ãã ãããã£ãåé¡ã«ã¶ã¤ãã度ã«ãéçºã¡ã³ãã¼ã§ã©ããªè¨è¨ãã§ããããã¢ã¤ãã¢ãåºãåã£ã¦ãã¾ããã
ããã§ã¯ãã©ããã£ãæ©è½ãFirestoreã§å®ç¾ãã«ããã®ããããã«å¯¾ãã¦ã©ããªè¨è¨ãã¿ã¼ã³ãããã®ãããããã®ã¡ãªããã»ãã¡ãªããã¯ä½ããæ¸ãã¦ãããã¨æãã¾ãã
ãªã¹ã表示ã«è¤æ°ã®ã³ã¬ã¯ã·ã§ã³ã®æ å ±ãå¿ è¦
æåã¯ããèªãããå 容ã§ãããã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ã®åé¡ã§ãã ããã³ã¬ã¯ã·ã§ã³ã®ãªã¹ãã表示ãããã¨ãã«ãåãªã¹ãã¢ã¤ãã ãã¨ã«å¥ã³ã¬ã¯ã·ã§ã³ã®ãã¼ã¿ãå¿ è¦ã«ãªãã±ã¼ã¹ã§ãã
ä¾ãã°Komercoã§ã¯ååã®ãªã¹ãã表示ããç»é¢ã§ãåã»ã«ã«ã·ã§ããã®æ å ±ã表示ãã¦ãã¾ãã
Firestoreã§ã¯åä¸ã®ã¯ã¨ãªã§åä¸ã®ã³ã¬ã¯ã·ã§ã³ããåå¾ã§ããªãå¶ç´ä¸ã次ã®ããããã®æ段ãåããã¨ã«ãªãã¾ãã
åé·å: åå¾ããã³ã¬ã¯ã·ã§ã³ã«å¥ã³ã¬ã¯ã·ã§ã³ã®æ å ±ãå«ããããã«ããã
ã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³: ã¯ã©ã¤ã¢ã³ãå´ã§ã³ã¬ã¯ã·ã§ã³ãå¥ã ã«åå¾ãã¦çµåããã
ã¡ãªã¿ã«ãæåã¯åä¸ã³ã¬ã¯ã·ã§ã³ã®åå¾ã§æ¸ãããè¨è¨ã§ãã¦ãã¦ãããã®å¾ã®æ¡å¼µã§å¥ã³ã¬ã¯ã·ã§ã³ã®ãã¼ã¿ãå¿ è¦ã«ãªããã¨ãå¤ãã¨æãã¾ãã Komercoãæè¿ã®ã¢ãããã¼ãã§ãååã®ã»ã«ã«ã·ã§ããã®æ å ±ãè¼ããããã«ãªãã¾ããã åé·åãããã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ã«ãããã®é¸æã¯ããµã¼ãã¹ãç¶ãã¦ããéã«å¿ ãçµé¨ãããã¨ã«ãªãã®ã§ã¯ãªãã§ããããã
å®æ ã¨ãã¦ã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ãå¤ããªããã¡
åé·åã«ã¯æ¬¡ã®ã¡ãªããã«ã¯ã
- ãªã¹ã表示ã«å¿ è¦ãªãã¼ã¿ã®åå¾ãä¸åã®ã¢ã¯ã»ã¹ã§æ¸ãã
- ã¯ã©ã¤ã¢ã³ãå´ã®å®è£ ãã·ã³ãã«ã«ãªãã
ãªã©ããããã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ã®ã¡ãªããã¯ã
- Firestoreã®ã¹ãã¬ã¼ã¸æ¶è²»ãå°ãªãã
- åé·åã®ä»çµã¿(Cloud Functionsã®å®è£ ç)ãä¸è¦ã
ãªã©ãæããããã¨æãã¾ãã
Komercoã¯ãã¾ãåé·åã®é¸æãã§ãã¦ãã¾ãããã¨ããã®ãåé·åã®ä»çµã¿ã®å®è£ ã»ã¡ã³ããã³ã¹ã³ã¹ãã大ãããªããã¡ã ããã§ãã ä¾ãã°å ã»ã©ã®ååã«ã·ã§ããã®æ å ±ãè¼ããä¾ã§ã¯ãåé·åãè¡ãå ´åãååã®ã³ã¬ã¯ã·ã§ã³ã«ã·ã§ããã®æ å ±ã®ä¸é¨ãCloud Functionsã§ä»ä¸ãã訳ã§ããã
- ã·ã§ããæ å ±æ´æ°æã«ãã®ã·ã§ããã®ååãã¹ã¦ãæ´æ°ããCloud Function
- ååæ å ±ã®æ°è¦ä½ææã«ã·ã§ããã®æ å ±ãåå¾ãã¦ä»ä¸ããCloud Function
- Firestoreã»ãã¥ãªãã£ã«ã¼ã«ã®ç¢ºèªã»å¤æ´
- Firestoreã¤ã³ããã¯ã¹ã®ç¢ºèªã»å¤æ´ï¼å¤§ãããã£ã¼ã«ããé¤å¤ãããªã©ï¼
- ï¼ãªãªã¼ã¹å¾ã®å ´åï¼ãã§ã«Firestoreã«åå¨ããååã«å¯¾ãã¦ã·ã§ããæ å ±ãä»ä¸ããä½æ¥
çã ãå¿ è¦ã«ãªãã¾ãã ãã¾ã管çãã¦ãããªãã¨ãåé·åã®Cloud Functionsãå¢ãç¶ããã©ã®ããã¥ã¡ã³ããæ´æ°ããã¨ä½ã«å½±é¿ãåºãã®ãåãããªãå¯è½æ§ãããã¾ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ã®å ´åã確ãã«ã¯ã©ã¤ã¢ã³ãå´ã®å®è£ ã³ã¹ãã¯å¢ãã¾ããã大æµã®å ´åã¯ã»ã«ãç»é¢ã«è¡¨ç¤ºãããç´åã«ãã¼ã¿åå¾ããå®è£ ãããã ãã§ãã ã»ã«ã«ç»åã表示ããéã«ããè¡ãå®è£ ã¨ä¸ç·ã§ãã ãã®ãããåºæ¬çã«ã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ã®é¸æãè¡ã£ã¦ããç¶æ³ã§ãã
åé·åããã¾ããã£ãä¾
Komercoã§åé·åããã¾ããã£ãä¾ã¨ãã¦ã¯ãååä¸è¦§ç»é¢ã®ç»ååå¾ã®é«éåãããã以åããã°ã§ãæ¸ãã¾ããã
ãã®ä¾ã®ããã«ã
- ã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ã§ã¯å¦çå®äºã¾ã§ã®æéãé ã
- 対象ã®å¦çé度ã¯ãµã¼ãã¹ã«ã¨ã£ã¦éè¦ã§ãã
ã¨ãã£ãå ´åã«ããã¦ãåé·åã®ä»çµã¿ã®å°å ¥ã³ã¹ãã«è¦åãã®ã§ã¯ãªããã¨æã£ã¦ãã¾ãã
Cloud Functionsã§åå¾ããã¨ããé¸æè¢ã«ã¤ãã¦
Cloud Functionsã§ã¸ã§ã¤ã³ãã¦ããè¿ããã¨ãèãããã¨ãããã¾ãããå人çã«ã¯ãã¾ããããªãææ³ã ã¨æã£ã¦ãã¾ãã çç±ã¯Firestoreã®ã»ãã¥ãªãã£ã«ã¼ã«ãç¡è¦ããåå¾ãå¯è½ã«ãªã£ã¦ãã¾ãããã§ãã
ã»ãã¥ãã£ã«ã¼ã«ã«ãã£ã¦èª°ãã¯ã©ã¤ã¢ã³ããå®è£ ãã¦ãæ³å®å¤ã®æ´æ°ã¯ãªãããªãã¨ããå®å¿æããããç¹ã«æ°ããã¡ã³ãã¼ãã¸ã§ã¤ã³ããã¨ãã«ãªã©ã«æå¹ã§ãã
ã©ããã¦ãCloud Functionsã§å®è£ ãããå ´åã¯ãã®ãããªã±ã¼ã¹ã«æ°ãã¤ãã¤ã¤ãFirestoreã¨åããªã¼ã¸ã§ã³ã§ä½æããã®ãããããã§ãã
ãªã¹ã表示ã«ãã¼ã¸ã£ã¼ãã¤ãã
Firestoreã§ç¹å®ã®ã³ã¬ã¯ã·ã§ã³ã®ãã¼ã¿ãä¸è¦§è¡¨ç¤ºãã¦ããå ´åãä¸çªç°¡åãªã®ã¯ã¢ããªä¸ã§ä¸çªä¸ã¾ã§ã¹ã¯ãã¼ã«ãããç¶ãå 容ã追å ãã¼ãããä»æ§ã§ãã ããã¯Firestoreã®startAfterãªã©ã®ã«ã¼ã½ã«å¥ã使ã£ãã¯ã¨ãªã¨ç¸æ§ãããããã§ãã
ä¸æ¹ã§å°ãã®ã¯ç¹å®ã®ãã¼ã¸ãæå®ãã¦ããã®ç¯å²ã®ãªã¹ããåå¾ãããã¨ã§ãã ç¹ã«PCã®å ´åã追å ãã¼ãããããã¼ã¸ã£ã¼ã§ãªã¹ããè¦ã¦ããæ¹ãä¸è¬çãã¨æãã¾ãã ãã¼ã¸ãæå®ããã¨ãããã¨ã¯ã¤ã¾ããåå¾éå§ä½ç½®ã¨åå¾åæ°ãã¯ã¨ãªã«å«ãããã°ããã®ã§ãããåå¾éå§ä½ç½®ã®æå®ã¯ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªã«ã¯ããã¾ããã
Komercoã®Webçã¯PCã§ã®å©ç¨ãæ³å®ãã¦ãããå®ç¾æ¹æ³ã«ã¤ãã¦ããè°è«ãã¾ããã
ããã¥ã¡ã³ãã«ä½çªç®ãã表ãçªå·ãä»ä¸ãã
ã¯ã©ã¤ã¢ã³ãçã«çæ³çãªç¶æ ã¯ãä½çªç®ãã示ããã£ã¼ã«ããããã¥ã¡ã³ãã«è¿½å ããããã¨ã ã¨æãã¾ãã åå¾ç¯å²ãæå®ãç°¡åã§ãå ¨é¨ã§ä½ä»¶ããããæå¾ã®ããã¥ã¡ã³ããåå¾ããã°åããã¾ãã
ãã ããã¯ä¸æ¹ã§ãããã¥ã¡ã³ãã®é åºå¤æ´ãåé¤ãçºçããå ´åã«ãå½±é¿ããã³ã¬ã¯ã·ã§ã³ã®çªå·ãæ¯ãç´ããCloud Functionsã§è¡ãå¿ è¦ãããã¾ãã é »ç¹ã«æ´æ°ããããããªã³ã¬ã¯ã·ã§ã³ã®å ´åã¯ãæ¸ãè¾¼ã¿æ°ã®ä¸éãªã©ã«æ³¨æãå¿ è¦ã§ãã
ãã¼ã¸æå®ä»¥å¤ã®æ¹æ³ãèãã¦ã¿ã
ä¾ãã°é±ã«1åå®æçã«æ´æ°ãããè¨äºã³ã³ãã³ãã®ãããªãã®ã®å ´åããã¼ã¸ã§ã¯ãªãå¹´æãæå®ãã¦ãã®ç¯å²ã®è¨äºãåå¾ããæ¹æ³ãèãããã¾ãã ããã§ããã°Firestoreã®ã¯ã¨ãªãæ¸ããã®ã§ãå®ç¾ã¯å®¹æã§ãã
å ¨ä»¶åå¾
å ã«æããæ¦ç¥ãåããªãå ´åããã¼ã¿éçã«åé¡ãªããã¨ãåæã«ãå ¨ä»¶åå¾ã®å¤æããããã¨ãããã¾ãã ããã¯æå¾ã®æ段ãªã®ã§ãä»æ§ã調æ´ãããªã©ãã§ããã ãå¥ã®è§£ã¯ç¡ããèããããã«ãã¦ãã¾ãã
æªèªã«ããã¸ãã¤ãã
ãµã¼ãã¹ããã®ãç¥ãããã¡ãã»ã¼ã¸æ©è½ãå®è£ ããã¨å¿ è¦ã«ãªãã®ãæªèªæ©è½ã§ãã æªèªã®ä¿åæ¹æ³ã«ã¤ãã¦ã¯ããã¤ããã¿ã¼ã³ãããã¾ãã
æªèªç®¡ç対象ã®ããã¥ã¡ã³ãã«ä¿åãã
æªèªç®¡ç対象ã®ã³ã¬ã¯ã·ã§ã³ã«å¯¾ãã¦ã
- é²è¦§ããã¦ã¼ã¶æ°ãéå®ããã¦ãã
- åã¦ã¼ã¶ã®æªèªã»æ¢èªç¶æ³ããä»ã®é²è¦§å¯è½ã¦ã¼ã¶ã«å ¬éããã¦ãã
ã®ã§ããã°ããã®ã³ã¬ã¯ã·ã§ã³èªä½ã«æªèªã»æ¢èªã表ãæ å ±ãå ¥ãã¦ãã¾ãã®ãããã¨æãã¾ãã æªèªã®æç¡ã®ç¢ºèªãã¯ã¨ãªã²ã¨ã¤ã§ç¢ºèªã§ãã¾ãããã¯ã©ã¤ã¢ã³ããµã¤ãã¸ã§ã¤ã³ãä¸è¦ã§ãã
Komercoã®ã¡ãã»ã¼ã¸æ©è½ãä¾ã«èª¬æãã¾ãã ãã®æ©è½ã¯ãã¯ãªã¨ã¤ã¿ã¼ã¨ã«ã¹ã¿ãã¼ã®1対1ãã£ãããè¡ããã®ã§ãã ãã£ããã¼ã«ã ã«å½ããRoomã³ã¬ã¯ã·ã§ã³ãããããã®ãµãã³ã¬ã¯ã·ã§ã³ã¨ãã¦åãã£ããã¡ãã»ã¼ã¸ã«å½ããMessageã³ã¬ã¯ã·ã§ã³ãããã¾ãã
ä¾ãã°ã¯ãªã¨ã¤ã¿ã¼ãã¡ãã»ã¼ã¸ãéä¿¡ããã¨ãMessageã³ã¬ã¯ã·ã§ã³ã«ããã¥ã¡ã³ãã追å ããã¾ãã
Cloud Functionã¯ãã®ã¤ãã³ããåãã¦ã親ã®Roomã®ããã¥ã¡ã³ããæ´æ°ããã«ã¹ã¿ãã¼ã®æªèªæã示ã isCustomerRead
ãã©ã°ã false
ã«ãã¾ãã
ã«ã¹ã¿ãã¼ã¯ isCustomerRead == false
ã§çµãè¾¼ããã¨ã§æªèªã¡ãã»ã¼ã¸ãè¦ã¤ãããã¾ãããMessageã³ã¬ã¯ã·ã§ã³ãåå¾ããªãã¦ããã®ãã£ããã«ã¼ã ã«æªèªããããã¨ãåããã¾ãã
æ¢èªç®¡çç¨ã®ãµãã³ã¬ã¯ã·ã§ã³ãä½ã
ããµã¼ãã¹ããã®ãç¥ãããã®ããã«ãå ¨ä½åãã®æ å ±ã«å¯¾ãã¦æªèªç®¡çãããå ´åãå ã®ä¾ã®ããã«ãç¥ããã®ããã¥ã¡ã³ãã«å ¨ã¦ã¼ã¶ã®æªèªæ å ±ãæ¸ãè¾¼ãã®ã¯ç¾å®çã§ã¯ããã¾ããã
ããã§ä¾ãã°ãã¦ã¼ã¶ã®ãµãã³ã¬ã¯ã·ã§ã³ã«æ¢èªç®¡çç¨ã³ã¬ã¯ã·ã§ã³ãä½æãããç¥ãããèªãã å ´åã¯ãã®ãç¥ããã®IDãæã¤ããã¥ã¡ã³ããæ¢èªç®¡çç¨ã³ã¬ã¯ã·ã§ã³ã«è¿½å ãã¾ãã ãç¥ãã表示æã¯ãã®ã³ã¬ã¯ã·ã§ã³ãæ¯è¼ããæ¢èªç®¡çç¨ã³ã¬ã¯ã·ã§ã³ã«åå¨ããªããã°æªèªã¨å¤æããã¾ãã
ãã ããã1ã¤ã§ãæ¢èªã®ãç¥ãããããã°ããã¸ã表示ããããã¨ãã£ãã¨ãã«ããç¥ãããæ¢èªç®¡çç¨ã³ã¬ã¯ã·ã§ã³ããææªå ¨ä»¶åå¾ããªãã¨åãããªãã¨ããåé¡ãããã¾ãã
æå¾ã«é²è¦§ããæ¥ä»ããåã®è¨äºãæªèªã¨ãã
ä¾ãã°ãç¥ããã§ããç¥ãããã¨ã«åå¥ã«æªèªç®¡çããå¿ è¦ããªãå ´åã¯ãæå¾ã«ãç¥ããä¸è¦§ãéããæ¥ä»ãè¦ãã¦ããããã以åã®ãç¥ãããæ¢èªã¨ãã¦ãã¾ãæ¹æ³ãããã¾ãã ãã®å ´åãæªèªã®æç¡ã¯ãã®æ¥ä»ã使ã£ã¦ã¯ã¨ãªãããã¨ãã§ãã¾ãã
ããã¥ã¡ã³ããã¨ã®æ¢èªç®¡çã®éè¦æ§ãä½ãå ´åã¯ããã¡ãã®ææ³ãããã¨æãã¾ãã
ã¾ã¨ã
Komercoã®çµé¨ããã¼ã¹ã«ãFirestoreã使ã£ãéçºã§å¤ãã®äººãæ©ã¿ãããªã±ã¼ã¹ã«ã¤ãã¦èª¬æãã¾ããã ã©ã®è¨è¨ãé¸ã¶ãã¯çµå±ä»æ§æ¬¡ç¬¬ã«ãªãã®ã§ãä»æ§ãããåæãã¦è¨è¨ãé¸ãã§ã¿ã¦ãã ããã
å¼ç¤¾ãã¾ã ã¾ã 試è¡é¯èª¤ä¸ãªã®ã§ãèªåã¯ãããã¦ãã¾ãï¼ãã¨ããã¢ã¤ãã¢ããæã¡ã®æ¹ããã²ã話èããã¦ãã ããã
å¾ç·¨ã¯ãFirebaseã«é¢ããä»çµåãè¡ã£ã¦ãéç¨ã³ã¹ããä¸ãã¦ãã話ããããã¨æãã¾ãã