无法在Firestore中选择ID

时间:2018-04-08 07:17:42

标签: javascript firebase google-cloud-firestore

我正在使用firestore,在用户Employee集合下我想删除使用id的特定员工。我的代码是

export const employeeSave = ({
    name,
    phone,
    shift,
    uid
}) => {
    const {
        currentUser
    } = firebase.auth();
    return (dispatch) => {
        firebase.firestore().collection('users').doc(currentUser.uid).collection('employees').doc(uid).update({
            name,
            phone,
            shift
        }).then(() => {
            dispatch({
                type: EMPLOYEE_SAVE_SUCCESS
            });
            Actions.employeeList({
                type: 'reset'
            });
        });
    };
};

2 个答案:

答案 0 :(得分:0)

听起来你只想打电话给删除

firebase.firestore().collection('users').doc(currentUser.uid).collection('employees').doc(uid).delete()

请点击此处查看更多https://firebase.google.com/docs/firestore/manage-data/delete-data

答案 1 :(得分:0)

.update需要一个对象或键/值对。所以试试:

.update({
 name: "joe",
 phone: "123-234-5567",
 shift: "night"
})