Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在Firestore中选择Id_Javascript_Firebase_Google Cloud Firestore - Fatal编程技术网

Javascript 无法在Firestore中选择Id

Javascript 无法在Firestore中选择Id,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我正在使用firestore,在user Employee collection下,我想删除使用id的特定员工。我的代码是 export const employeeSave = ({ name, phone, shift, uid }) => { const { currentUser } = firebase.auth(); return (dispatch) => { firebase.fi

我正在使用firestore,在user Employee collection下,我想删除使用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'
            });
        });
    };
};

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

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

有关详细信息,请参见此处。更新需要对象或键/值对。因此,请尝试:

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

请将您的代码包装在代码配额中``或者使用此帮助以便能够阅读和理解您的代码:感谢您的回复,我做了与您提到的相同的事情,然后它抛出了此错误“relativePath.split不是函数”请帮助您需要更好地使用javascript。这不是firebase的问题。非常感谢您回复删除所选员工,我正在使用以下代码导出const employeeDelete=({uid})=>{const{currentUser}=firebase.auth();firebase.firestore().collection('users').doc(currentUser.uid).collection('employees').doc(uid).delete()。然后(=()>{Actions.employeeList({type:'reset'});});但它抛出了一个错误“relativePath.split不是函数”请帮助我