我试着第一次使用火药库。我创建了非常开放的规则:
service cloud.firestore {
match /databases/{database}/documents {
// Make sure the uid of the requesting user matches name of the user
// document. The wildcard expression {userId} makes the userId variable
// available in rules.
match /users/{userId} {
当用户提交请求时,将使用其各自的数据创建firestore文档。这个文档的创建触发了一个firebase function,然后该将电子邮件发送到一个特定的地址。它可以正常工作,但是如何从函数中得到返回成功/错误警报(客户端)的承诺,当这封电子邮件已经发送/不发送.。
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
exports.request = functions.firesto
我正在测试Firestore安全规则,并进行了以下设置: // firestore.spec.js
/**
* Creates a new client FirebaseApp with authentication and returns the Firestore instance.
* Also optionally seeds the project with mock data
*/
setupFirestoreDb = async (auth, data) => {
// initialize test app
const PROJECT_ID = "
我试图从一个云函数中在不同的节点中创建以下两个文档,但不确定如何返回这两个文档。
// Listen to .onCreate trigger
exports.createUserAndProfile = functions.auth.user().onCreate((user) => {
// Create a new user (only the user themselves can access this)
const newUser = admin.firestore().doc(`/users/${user.uid}`).set({
announcement
我制作了一个反应本地应用程序,在ios上一切都很完美地运行着,直到我在android上运行它,我得到了这个错误。
Possible Unhandled Promise Rejection (id: 1):
Error: [firestore/permission-denied] The caller does not have permission to execute the specified operation.
NativeFirebaseError: [firestore/permission-denied] The caller does not have permission t
当我将一个Date对象写到我的Firestore中时,一切都能正常工作,并且我可以在数据库中看到一个以"timestamp“类型存储的日期。如果我试图将一个Date对象传递给一个云函数,我不知道为什么,但当我将它从云函数存储到firestore DB时,它是一个空对象。 firebase.functions().httpsCallable("myFunction")({date: new Date()}) <---- // this doesn't work 因此,我决定在将Date对象发送到云函数之前,在客户端将其转换为firestore时间戳。如
在医生里,写着:
使用get()和get()函数,您的安全规则可以根据数据库中的其他文档评估传入的请求。
这对我来说没问题,这个例子对我来说是有意义的:
service cloud.firestore {
match /databases/{database}/documents {
match /cities/{city} {
// Make sure a 'users' document exists for the requesting user before allowing any writes to the 'cities
我正在使用来创建我的web应用程序的新用户。
// function to create user and store additional info in firestore
exports.createUser = functions
.https.onCall((data, context) => {
admin.auth().createUser({
phoneNumber: data.phoneNumber,
displayName: data.displayName,
}).then((user) => {