我尝试将此功能部署到firebase:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const ref = admin.databse().ref();
exports.creatUserAccount = functions.auth.user().onCreat(event =>{
const uid = event.data.uid;
const newUserRef = ref.child('/users/${uid}');
return newUserRef.set({
uid: uid
});
});
但是Node.js把我扔了:" admin.databse不是一个函数"。我该怎么办?
答案 0 :(得分:1)
您输错了,admin.databse().ref();
需要admin.database().ref();
答案 1 :(得分:0)
database()
是实例的功能
所以你应该使用如下。
admin.initializeApp(functions.config().firebase);
const ref = admin.databse().ref();
to =>
var instance = admin.initializeApp(functions.config().firebase);
const ref = instance.database().ref();