ошибка обновления базы в javascript - PullRequest
0 голосов
/ 20 марта 2020

Я пытаюсь обновить одно свойство в моей базе данных firebase, но возникла ошибка. Ошибка: Reference.update не удалось: первый аргумент должен быть объектом, содержащим дочерние элементы, для замены

analysis = (actionid)=>{


    //check if it is't the first command
    console.log('before definition of flage')
    var flag=false;
    console.log('hiii')
    firebase.database().ref('userActions/').once ('value',(snap)=>{ 
        console.log("iafter definition ")
        snap.forEach((child)=>{
            if(child.val().userID===firebase.auth().currentUser.uid && child.val().ActionID== actionid){
            plus=parseInt(child.val().Repetition)+1;
            console.log("before first use")
            flag=true;
            console.log("before first use 2")
            firebase.database().ref('userActions/'+child.key).update(

                Repetition=plus, 

            ).then(() => {
                console.log('inserted the update')
            }).catch((error)=>{
                console.log(error)
            });
         } })
    }
    ).finally(()=>{
        if(flag===false)
        this.insertUserAction();
    });

}

1 Ответ

0 голосов
/ 20 марта 2020

В этом коде:

        firebase.database().ref('userActions/'+child.key).update(
            Repetition=plus, 
        )

Похоже, вы вместо этого хотели передать объект, используя фигурные скобки для определения объекта, содержащего свойства для обновления:

        firebase.database().ref('userActions/'+child.key).update({
            Repetition=plus, 
        })
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...