내 응용 프로그램에서 사용자를 인증 한 후 내 firestore userProfile 컬렉션에 사용자 프로필 문서를 만드는 클라우드 기능을 만들고 싶습니다.firestore에서 클라우드 기능을 사용하여 문서 만들기
이 내가 USERPROFILE라는 컬렉션을 가지고있는 경우 FireStore의 클라우드 데이터베이스에서
TypeError: admin.firestore(...).ref is not a function
at exports.createProfile.functions.auth.user.onCreate.event (/user_code/index.js:13:30)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:59:27)
at next (native)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:53:36)
at /var/tmp/worker/worker.js:695:26
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
을 오류 수신하고있는 클라우드 기능 여기
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
//function that triggers on user creation
//this function will create a user profile in firestore database
exports.createProfile = functions.auth.user().onCreate(event => {
// Do something after a new user account is created
return admin.firestore().ref(`/userProfile/${event.data.uid}`).set({
email: event.data.email
});
});
내 전체하는 index.js 파일입니다 어디에 인증 후에 사용자에게 부여 된 고유 ID로 문서를 작성해야합니다.
좋아 보인다. –
이 오류가 발생하면 admin.firestore()를 참조하십시오. ref는 함수가 아닙니다. –
전체 코드 파일과 전체 오류를 표시 할 수 있습니까? –