Unable to use firebase.firestore.FieldValue.increment

◇◆丶佛笑我妖孽 提交于 2021-01-29 10:05:24

问题


There is a method provided by firestore to increment a numeric value.

But I was not able to use the function because it is undefined.

I tried updating firebase in npm, tried reinstalling firebase. I currently have the 5.10.1 version of firebase.

import firebase from "../base";
...
someHandler = () => {
  someRef.update({
      count: firebase.firestore.FieldValue.increment(1)
  });
}

回答1:


The problem is that the FieldValue is not accessible through the app instance.

So I solved my problem by importing directly from "firebase" instead of my local file which exports an initialized firebase instance.



来源:https://stackoverflow.com/questions/55897154/unable-to-use-firebase-firestore-fieldvalue-increment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!