2016-11-05 2 views
4

필자는 firebase 응용 프로그램과 함께 탄력적 인 검색 색인을 구현하여 특별 전체 텍스트 검색과 지리 정보 검색을보다 잘 지원할 것입니다. 따라서 firebase 데이터를 탄성 검색 인덱스에 동기화해야하며 모든 예제에는 firebase 이벤트를 수신하는 서버 프로세스가 필요합니다.서버가없는 firebase 이벤트를 통해 Google Cloud 기능을 실행할 수 있습니까?

https://github.com/firebase/flashlight

그러나 firebase 노드에 삽입하여 Google 클라우드 기능을 실행할 수 있다면 좋을 것입니다. 나는 구글 클라우드 기능이 다양한 트리거를 가지고있는 것을 보았습니다 : pub sub, storage and direct ... 중개 서버없이 firebase node 이벤트에 연결할 수 있습니까? 여기

답변

4

내가 믿는 Fire Base 용 구름 기능는 당신이 찾고있는 것입니다. 는 여기에 몇 가지 링크입니다 :

+0

그래, 그게다고 생각해 .- 최근에 발표 한 게 틀림 없어? – MonkeyBonkey

+0

@MonkeyBonkey 예 - 동영상이 어제 출신입니다. Google에서 대화를 포함하도록 답변을 업데이트했습니다. 다음 – bastien

12

firebaser는

우리는 Cloud Functions for Firebase을 발표했다. 이렇게하면 Firebase 이벤트 (예 : 데이터베이스 변경, 로그인하는 사용자 등)에 대한 응답으로 Google 서버에서 JavaScript 기능을 실행할 수 있습니다.

+0

아래와 같이 자바 스크립트를 작성했다 - 당신이 슬라이드로 연결되는 링크를해야합니까? 나는 github readme에서 그것을 볼 수 없다 – MonkeyBonkey

+0

@Frank 이것에 대한 어떤 업데이 트? – Hamid

+0

Firebase 웹 앱에서 실시간으로 데이터 저장소를 읽고 쓸 수있는 방법 (실시간이 필요하지 않을 때 장기 DB 저장) – Gary

0

이 그래, 당신은 서버없이 중포 기지 이벤트를 통해 Google 클라우드 기능을 트리거 할 수 있습니다. 문서별로 Firebase는 사용자가 firebase 데이터베이스에 쓸 때 예를 들어 클라우드 기능을 사용하여 알림을 보낼 수 있습니다. 이를 위해

, 나는 그것을 확인합니다 멋진

'use strict'; 

const functions = require('firebase-functions'); 
const admin = require('firebase-admin'); 
admin.initializeApp(functions.config().firebase); 

exports.sendNotification = functions.database.ref('/articles/{articleId}') 
     .onWrite(event => { 

     // Grab the current value of what was written to the Realtime Database. 
     var eventSnapshot = event.data; 
     var str1 = "Author is "; 
     var str = str1.concat(eventSnapshot.child("author").val()); 
     console.log(str); 

     var topic = "android"; 
     var payload = { 
      data: { 
       title: eventSnapshot.child("title").val(), 
       author: eventSnapshot.child("author").val() 
      } 
     }; 

     // Send a message to devices subscribed to the provided topic. 
     return admin.messaging().sendToTopic(topic, payload) 
      .then(function (response) { 
       // See the MessagingTopicResponse reference documentation for the 
       // contents of response. 
       console.log("Successfully sent message:", response); 
      }) 
      .catch(function (error) { 
       console.log("Error sending message:", error); 
      }); 
     }); 
관련 문제