本文介绍了Cloud Function和Firebase函数有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

云功能和Firebase功能看起来都一样。
请描述每个的用例。
在这两者中都有HTTP函数。
$ b $

云计算函数中,

  exports.helloHttp =函数helloHttp(req,res){
res.send(`Hello $ {req.body.name ||'World'}! `);
};

以及 Firebase功能

  exports.helloWorld = functions.https.onRequest((request,response)=> {
response.send(Hello from Firebase!)
});

两个conncetion之间的区别是什么

解决方案

没有任何产品叫做Firebase函数。

有三个独立的东西:


  1. Google云端函数,允许您在Google的基础架构中运行JavaScript代码片段,以响应事件

  2. Firebase的云端函数,触发Google Firebase基于Firebase中的事件的功能(例如数据库或文件写入,用户创建等)
  3. Firebase SDK for Cloud功能,其中包括一个库(名为 firebase-functions )在您的函数代码中用于访问Firebase数据(例如写入数据库的数据的快照)



因此,Firebase提供了一个围绕Google云端函数(相对较薄)的封装,使后者更易于使用,并将其与Firebase集成。从这种意义上来说,它类似于Firebase将Google云端存储集成到Cloud Storage for Firebase(以前称为Firebase存储)中的方式。



如果您使用的是Google Cloud没有Firebase的平台,那么您应该使用普通的。如果您使用的是Firebase,或者您是对云端功能感兴趣的移动开发者,则应使用。

Cloud functions and Firebase functiosn both look the same.Please describe the use case of each.In the both there is HTTP function is there.

In the Cloud function

exports.helloHttp = function helloHttp (req, res) {
  res.send(`Hello ${req.body.name || 'World'}!`);
};

and in the Firebase function

exports.helloWorld = functions.https.onRequest((request, response) => {
  response.send("Hello from Firebase!");
 });

What is difference between both conncetion

解决方案

There is no product called Firebase Functions.

There are three separate things:

  1. Google Cloud Functions, which allow you to run snippets of JavaScript code in Google's infrastructure in response to events
  2. Cloud Functions for Firebase, which triggers Google Cloud Functions based on events in Firebase (such as database or file writes, user creation, etc)
  3. Firebase SDK for Cloud Functions, which includes a library (confusingly called firebase-functions) that you use in your Functions code to access Firebase data (such as the snapshot of the data that was written to the database)

So Firebase provides a (relatively thin) wrapper around Google Cloud Functions, to make the latter product easier to use and integrate it with Firebase. In that senses it is similar to how Firebase integrates Google Cloud Storage into "Cloud Storage for Firebase" (formerly known as Firebase Storage).

If you're using Google Cloud Platform without Firebase, then you should use plain Google Cloud Functions. If you're on Firebase or if you're a mobile developer interested in Cloud Functions, you should use Cloud Functions for Firebase.

这篇关于Cloud Function和Firebase函数有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:09