ç§ã¯ãã£ãšåã«Firebaseã§åããããšæã£ãŠããŸããããé©åãªãããžã§ã¯ããåŸ ã£ãŠããŸããã ãããŠç§ã¯åŸ ã£ãïŒMVPãªãã£ã¹äºçŽã·ã¹ãã ã ããã¯MVPã§ãããããããã¯ãšã³ãã®ããžãã¹ããžãã¯ã¯ããªãåå§çã§ãã ããã«ãiOSäžã®ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ã¯Firebaseã«æ¥ç¶ãããŸãã ãµãŒãã¹ã䜿çšããããã®çæ³çãªã±ãŒã¹ã®ããã«èŠããŸãããå®è£ äžã«ããã€ãã®åé¡ã«çŽé¢ããå¿ èŠããããŸãããããã«ã€ããŠã¯åŸã§èª¬æããŸãã
ããããæåã«ããã¹ãŠã®èª€è§£ãæé€ããããšæããŸãã Firebaseã䜿çšããããã«åŠç¿ããå¿ èŠããã2ã€ã®ããšã次ã«ç€ºããŸãã
- ããã¯ããã¯ãšã³ãã§ã¯ãªããããŒã¿ããŒã¹ã§ãã ãµãŒããŒåŽã®ãªãFirebaseã®ã¢ããªã±ãŒã·ã§ã³ã®ãã°ãããäŸã¯å¿ããŠãã ãããããã¯ä»ã®ãšããéæäžå¯èœã§ãã
- ããã¯ãã¹ãŠã®é·æãšçæãæã€NoSQLã§ãã
ããŒã¿èªäœã®æ§è³ªã«åºã¥ããŠãããŒã¿ãä¿åãããœãªã¥ãŒã·ã§ã³ãéžæããå¿ èŠããããŸãã Firebaseã«ã¯æ¬ ç¹ããããŸãã
- ãã®ç¯å²ã¯NoSQLãœãªã¥ãŒã·ã§ã³ãããã¯ããã«å°ããã§ãã
- Firebaseã¯ãããŒã¿ããã§ãããããšãã«å€§å¹ ã«å¶éããå¿ èŠã«å¿ããŠåæã«è€æ°ã®å Žæã«ããŒã¿ãæžã蟌ã¿ãŸãã
- ãã¹ãŠã®ããŒã¿æ§é ããã¯ã»ã©é ããFirebaseã§äœæ¥ããã®ã䟿å©ã§ãã
ããããMVPã®éçºãè¿ éã«éå§ããããã«å€ãã®å©ç¹ãåŸãããšãã§ããããŒã«ã¯ããã³ãã«æšãŠãã®ãæ®å¿µã§ãã ãŸãã匱ç¹ã¯ããªãã«å¹²æžããå Žåã«ä¿®æ£ã§ããŸãã
åæ
ããã«ãã§ãŒã³ã®äºçŽã·ã¹ãã ãéçºããŠãããšããŸãã
ãã®ãããªãšã³ãã£ãã£ããããŸãïŒ
- ããã«
- æ°
- ã¯ã©ã€ã¢ã³ã
- äºçŽ
ãããSQLããŒã¿ããŒã¹ã«å®è£ ããæ¹æ³ã¯ç解ã§ããŸãããªã³ã¯ä»ãã®4ã€ã®ããŒãã«ãããããã€ã³ãããããŸãã
ãããNoSQLïŒFirebaseïŒã«å®è£ ããæ¹æ³ã¯ïŒ ãšã³ãã£ãã£ãçžäºã«ãã¹ãããŠã¿ãããšãã§ããŸãïŒ
{ ââ: { ⊠ââ: { ââ: { ??? }, ... } } }
ããã§çåãçãå§ããŸãïŒéšå±ã®ãã¹ãŠã®äºçŽã«æè³ãã䟡å€ã¯ãããŸããïŒ ãããŠã©ãã«é¡§å®¢ãæè³ããŸããïŒ ç NoSQLã®åé¡ã¯ãå€ãã®å ŽåãããŒã¿ãè€è£œããå¿ èŠãããããšã§ãã
2çªç®ã®ãªãã·ã§ã³ããããŸããSQLãšåæ§ã®æ¹æ³ã§NoSQLã䜿çšããåãšã³ãã£ãã£ã®ã«ãŒããªããžã§ã¯ããäœæããä»ã®ãªããžã§ã¯ãã®IDãä¿åããããšã§æ¥ç¶ãç¶æããŸãã
ãããããä»ã®NoSQLããŒã¿ããŒã¹ã§ãããã®åé¡ã«å¯ŸåŠããæ¹ãç°¡åã§ãããFirebaseã§ã¿ã¹ã¯ã®è§£æ±ºçãèŠã€ããããšãã§ããŸããã§ããã
ã©ã®ãªãã·ã§ã³ãéžæããŠããåãåé¡ããããŸããããŒã¿ã®è€éãªéžæãã§ããªãããšã§ãã ç¹å®ã®ã¯ã©ã€ã¢ã³ãã®äºçŽãªã¹ããååŸãããå Žåã¯ã©ãããŸããïŒ ãããã®äºçŽã¯ç°ãªãéšå±ãããã«ã«åã蟌ãŸããŠããå¯èœæ§ããããæ§é ãå¹³åŠãªå ŽåãFirebaseã¯ããã€ãã®ãã©ã¡ãŒã¿ãŒã«åŸã£ãŠããŒã¿ããã£ã«ã¿ãŒåŠçã§ããŸããïŒãã®åé¡ã¯StackOverflowã§ãè°è«ãããŸããïŒã äžè¬ã«ã顧客ãšäºçŽæ¥ã§éžæãããå ŽåãFirebase SDKã¯åœ¹ã«ç«ã¡ãŸããã
ããã¯ãšã³ãã§ãã®åé¡ã解決ããããšããããšãã§ããŸããã1ã€ã®ãã©ã¡ãŒã¿ãŒã§ãã£ã«ã¿ãŒåŠçãããããŒã¿ã®éžæããã³ãã¢ãŠãããããã«èªåã§ãã£ã«ã¿ãŒåŠçããå¿ èŠããããŸãã ããã¯åãå ¥ããããŸããã
ã©ããã
Firebaseãè€éãªããŒã¿ãµã³ããªã³ã°ã«äœ¿çšããªãã§ãã ããã Node.jsã®ããã¯ãšã³ããšã以äžã§èª¬æããããŒã«ã®ãããããããã«åœ¹ç«ã¡ãŸãã
Elasticsearch
ããã¯ã Luceneã䜿çšããJavaã§èšè¿°ãããJSON REST APIãåããæ€çŽ¢ãšã³ãžã³ã§ãã 詳现ã¯å ¬åŒãŠã§ããµã€ãã§èªãããšãã§ããFirebaseãšçµã¿åãããŠããã«æ€èšãéå§ããŸãã
èšçœ®
ãµãŒããŒã«ElasticSearchãé 眮ããå¿ èŠããããŸãïŒæ瀺ã«åŸã£ãŠç°¡åã«å®è¡ã§ããŸãïŒã Firebaseãšçµ±åããå¿ èŠãããå Žåãã€ãŸãFirebaseããŒã¿ããŒã¹ããæ€çŽ¢ã€ã³ããã¯ã¹ãäœæããå¿ èŠããããŸãã Firebaseã®å ¬åŒçµ±åã䜿çšããŸããã éå§ããã«ã¯ããªããžããªãããŠã³ããŒãããäŸåé¢ä¿ãã€ã³ã¹ããŒã«ããŠãFirebaseã®ããŒãæ§æã«è¿œå ããå¿ èŠããããŸãã
ãã®ãœãªã¥ãŒã·ã§ã³ã§ã¯ãããã€ãã®çæãèŠã€ãããŸããã
- ããã¯Node.jsäžã®ã¹ã¿ã³ãã¢ãã³ã¢ããªã±ãŒã·ã§ã³ã§ãããããã¯ãšã³ãã«é¢é£ä»ããã®ã¯å°é£ã§ãã
- ElasticSearchã®é©åãªã€ã³ããã¯ã¹ãäœæããã®ã¯ç°¡åã§ã¯ãªããFirebaseããŒã¿ããŒã¹ãšã®ããŒã¿åæã¯ååã§ã¯ãããŸããã
- ãã£ãŒã«ãã¿ã€ãã¯èªåçã«å²ãåœãŠãããŸãã
ãã®ãããªåçŽãªäŸã§ããããæããŠãã ããã 建ç©ã®ãªã¹ããšãã®èª¬æãšåº§æšããããŸãã ElasticSearchã§ã¯ãæ€çŽ¢ã€ã³ããã¯ã¹ãäœæãã段éã§ã建ç©ã®å°ç座æšãæ åœãããã£ãŒã«ããäºåã«å®£èšããå¿ èŠããããŸãã ãšã³ãžã³ãFirebaseãšçµ±åããŠãããã®ããã»ã¹ãå¶åŸ¡ããããšã¯ã§ããŸãããããã¹ãŠã®ããŒã¿ãåã«åæããŠãããŒã¿ã¿ã€ããèªåçã«æ±ºå®ããŸãã
ElasticSearchã¯ç¡æã§ããã®å¶åŸ¡ããããµãŒãã¹ã«ãããã€ãããŸã-ããã¯ãã©ã¹ã§ãã ããããåæã«ãäºåã«æ€èšããå¿ èŠãããå±éãšã»ãã¥ãªãã£ã®åé¡ãããã€ããããŸãã
äŸïŒElastic Searchãå€éšã¯ãšãªã«äœ¿çšããããŒããéããŠããŸãã åãããŒããæ€çŽ¢ã€ã³ããã¯ã¹ã®èšé²ãšç®¡çã«äœ¿çšããããããããã«ããè匱æ§ãçããŸãã ãã®ãããªç£èŠã®çµæãšããŠèããããã®ã¯ãæ€çŽ¢ã€ã³ããã¯ã¹ã®åé€ãŸãã¯ããŒã¿ãžã®ããŒã¿ã®å ¥åã§ãã ãããã£ãŠãæåã¯ããã®ããŒãã¯ElasticSearchãã€ã³ã¹ããŒã«ãããŠããåããã·ã³ããã®ã¯ãšãªã«å¯ŸããŠã®ã¿éããŠããŸãã
æåŸã«ããŠãŒã¶ãŒãElasticSearchãããã³ããã¯ãšã³ãéã®çžäºäœçšãå®è£ ããæ¹æ³ã®åé¡ã¯éçºè ã«ããã£ãŠããŸãã
ã¢ã«ãŽãªã¢
SaaSæ€çŽ¢ãœãªã¥ãŒã·ã§ã³ã ææã§ãããç¡æãã©ã³ããããŸãã äŸ¡æ Œè¡šããã³ãã®ä»ã®è©³çŽ°ã¯ã å ¬åŒãŠã§ããµã€ãã§èŠã€ããããšãã§ããŸãã
Firebaseãšã®çµ±åã¯ã å ¬åŒã®jsã©ã€ãã©ãªã䜿çšããŠå®è£ ãããŸã ã ã€ã³ã¹ããŒã«ããã³èµ·åããã»ã¹ã®è©³çŽ°ã¯readmeã§èª¬æãããŠãããæåã®è©Šè¡ã§ããŸããããŸããã
çµ±åã¯æ¬¡ã®ããã«ãªããŸãã
var algoliasearch = require('algoliasearch'); ⊠var client = algoliasearch(config.algolia.applicationID, config.algolia.apiKey); // Algolia var indexRooms = client.initIndex('rooms'); // Algolia rooms.once('value', initInde); // rooms â reference Firebase function initIndex(dataSnapshot) { var objectsToIndex = []; // Algolia var values = dataSnapshot.val(); // snapshot'a for (var key in values) { // room if (values.hasOwnProperty(key)) { var firebaseObject = values[key]; firebaseObject.objectID = key; // id Algolia Firebase objectsToIndex.push(firebaseObject); // } } indexRooms.saveObjects(objectsToIndex, function(err, content) { if (err) { console.log('error'); return; } console.log('success'); return; }); }
ãã®çµæãFirebaseãããã¹ãŠã®éšå±ãªããžã§ã¯ããå«ãæ€çŽ¢ã€ã³ããã¯ã¹ãã¢ã«ãŽãªã¢ã§ååŸããŸãã ã€ã³ããŒãããã»ã¹äžã«ãããŒã¿ããŒã¹å ã®å¥ã®ãªããžã§ã¯ãããããã«åãååŸãããªã©ãããŒã¿ãè¿œå åŠçã§ããããšã«æ³šæããŠãã ããã
ã€ã³ããã¯ã¹ãäœæããåŸã¯ãã€ã³ããã¯ã¹å šäœãæŽæ°ããäºå®ã¯ãããŸãããä»åŸãFirebaseã§ã€ãã³ããç£èŠããŠåŠçããŸãã
rooms.on('child_added', addOrUpdateObjectRooms); rooms.on('child_changed', addOrUpdateObjectRooms); rooms.on('child_removed', removeIndexRooms);
Algoliaã䜿çšããå¯äžã®æ¬ ç¹ã¯ãSaaSã®æ¯æããå¿ èŠã«ãªãããšã§ãã ããããMVPã®å Žåãç¡æã®é¢çšã§ååã§ãããFirebaseã§å€§èŠæš¡ãªãããžã§ã¯ããè¡ãããšãèãã人ã¯ã»ãšãã©ããŸããïŒç§ã¯é¡ã£ãŠããŸãïŒã
ãã®çããããã€ãã¹ãšã¯å¯Ÿç §çã«ãåæãæ€çŽ¢ã€ã³ããã¯ã¹ãæ€çŽ¢ã¯ãšãªã®ãã¥ã¢ã³ã¹ã«ã¢ã¯ã»ã¹ã§ãã䟿å©ãªç®¡çããã«ãçšæãããŠããŸãã
éèŠãªãã©ã¹ã¯ãã¢ãã€ã«ãã©ãããã©ãŒã ããããã¯ãšã³ããã¬ãŒã ã¯ãŒã¯ãŸã§ããããããã®ã«å¯Ÿå¿ããSDKã®ååšã§ãã ç§ã¯æ¬è³ªãæãäžããŸããã§ããããiOSéçºè ã¯ãRESTããã䟿å©ã ãšèšããŸããã
Algoliaãè©ŠããŠã¿ãããšããå§ãããŸããFirebaseãšã®çµ±åãåªããŠãããã€ã³ã¹ããŒã«ãç°¡åã§ãæçµçã«ã¯åæãšSDKãåããã³ã³ãœãŒã«ãå ¥æã§ããŸãã ç§ã¯æè¡çãªè©³çŽ°ãç¡èŠããããã©ãŒãã³ã¹ãšé床ãåæããŸããã§ãããããã¯è€éã§å¥åã®ãããã¯ã§ãã
ãŸãšã
ãã®ããªãåçŽãªã·ã¹ãã ã®å©ç¹ã¯æçœã§ãã ååŸãããã®ïŒ
- ããŒã¿ããã¹ãŠã®èªã¿åãæäœãããã³åçŽãªé競åèŠæ±ãæ ŒçŽããããã®Firebaseã
- ãã¹ãŠã®ç«¶åã¯ãšãªãšè€éãªããžãã¹ããžãã¯+ Algolia / ElasticSearchãµãŒãã¹çšã®Node.jsã
- æ€çŽ¢ããã³è€éãªããŒã¿ååŸã®ããã®Algolia / ElasticSearchã
Firebaseã®å©ç¹ã¯ãã¹ãŠãããŸãããNode.jsã§ããŒã¿ãè€è£œããããè€éã§é ãéžæãæŽçãããããå¿ èŠããããšããæ¬ ç¹ã¯ãããŸããã ãã®ç¶æ³ã§ã¯ãäºçŽã·ã¹ãã ããŸãã¯ãã©ã³ã¶ã¯ã·ã§ã³ãšè€éãªããŒã¿ãµã³ãã«ãå¿ èŠãšãããã®ä»ã®ã¿ã¹ã¯ãç°¡åã«å®è£ ã§ããŸãã ããšãã°ããšã¢ã³ã³ãšãã«ã³ããŒãåãã2人çšã®ç¹å®ã®æ¥ã®éšå±ãæåã«éžæããŠããäºçŽãããšãéšå±ããã§ã«å æãããŠããããåã³å æãããããšãæããããšã¯ãããŸããã 確ãã«ãäžéšã®ããŒã¿ã¯è€è£œããå¿ èŠããããŸãããããŒã¿ããŒã¹ã§ã¯ãªãæ€çŽ¢ã€ã³ããã¯ã¹èªäœã«ã®ã¿å«ãŸããŸãã
Firebaseãé©åã«äœ¿çšããããšã§ãããŒã¿ã®ã¢ã¯ã»ã¹ãšä¿åã«å®å šã«åãå ¥ãããããœãªã¥ãŒã·ã§ã³ã«ãªããŸãã ããŒã¿ã¯ãã©ã€ããªã§ãããééã£ãããŒã¿æ§é ãŸãã¯ããŒã¿ã®æäœæ¹æ³ãéžæãããšãé倧ãªéçºäžã®åé¡ã«çŽé¢ããããšãåžžã«èŠããŠãããŠãã ããã
Firebaseã®çµ±åã«é¢ããèšäºãèšäºã®ã³ã¡ã³ãã«ã³ã¡ã³ãããåŸ ã¡ããŠããŸãã ãããããé¡ãããŸãïŒ