我是React Native的新手,我已经开始在firebase中使用react native,当我在firebase中输入部门名称时,我必须确保Firebase中没有重复的数据,请帮忙
这是我的firebase函数,正在添加部门,取自于本机形式。
export const addDepts = (name,description,department,purpose) => {
//console.log(name);
const uuidv1=require('uuid/v1');
uuidv1();
db.database().ref('/departments').push({
name,
description,
department,
purpose,
}).then((data)=>{
//success callback
console.log('data ' , data)
alert("Department added successfully!")
}).catch((error)=>{
//error callback
console.log('error ' , error)
});
};