小编pep*_*epe的帖子

Firebase firestore云功能显示错误:无效使用"undefined"类型作为Firestore参数

我有一个项目将货币详细信息添加到firestore数据库中,我的项目正在使用ionic 3

每当我向集合添加新文档时,触发函数onCreate()将执行并更新名为"updated"的文档.

但触发功能始终显示错误.

Error: Invalid use of type "undefined" as a Firestore argument.
    at Object.exports.customObjectError.val [as customObjectError] (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/validate.js:164:14)
    at Function.encodeValue (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:808:20)
    at Function.encodeFields (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:678:36)
    at Function.fromObject (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:218:55)
    at WriteBatch.set (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/write-batch.js:291:39)
    at DocumentReference.set (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/reference.js:419:8)
    at Object.<anonymous> (/user_code/lib/index.js:28:10)
    at next (native)
    at /user_code/lib/index.js:7:71
    at __awaiter (/user_code/lib/index.js:3:12)
Run Code Online (Sandbox Code Playgroud)

sombody请帮忙..

我花了很多时间.

这是代码:

import * as functions from 'firebase-functions';

const admin = require('firebase-admin');
admin.initializeApp();

exports.createCurrency = functions.firestore
.document('Exchange/{ExchangeId}')
.onCreate( async (snap, context) => {

const id: string = snap.data().id;
const branchName: string = snap.data().branchName;
const …
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-functions google-cloud-firestore

23
推荐指数
1
解决办法
1万
查看次数

Firebase Firestore 中合并和合并字段的区别

我可以通过以下方法将数据传输到 Firebase Firestore 文档:

1) 添加()

2)设置()

我很清楚如何将数据添加到 Firestore,其中没有任何混淆。但是我的问题是 Firebase Firestore 中的“set”方法有两个 setOption,例如合并和合并字段。这两个设置选项有什么区别,我认为这两个选项都在做同样的工作。如何实现 setOption 'mergeFIeld'?我找不到它的任何文档。

firebase google-cloud-firestore angular6

9
推荐指数
3
解决办法
2860
查看次数

Firebase Firestore显示警告

我正在使用ionic 3和firebase firestore作为数据库进行项目.

但是,每当我进行CRUD操作时,我的firebase firestore都会显示警告.

 index.esm.js:77 [2018-05-02T05:45:40.408Z]  @firebase/firestore: 
 Firestore (4.13.0): 
 The behavior for Date objects stored in Firestore is going to change
 AND YOUR APP MAY BREAK.
 To hide this warning and ensure your app does not break, you need to 
 add the
 following code to your app before calling any other Cloud Firestore 
 methods:

 const firestore = firebase.firestore();
 const settings = {/* your settings... */ timestampsInSnapshots: 
 true};
 firestore.settings(settings);

 With this change, timestamps stored in Cloud Firestore will be read …
Run Code Online (Sandbox Code Playgroud)

firebase ionic3 google-cloud-firestore

3
推荐指数
1
解决办法
6852
查看次数

获取 Firebase Firestore 集合中最后创建的文档

有没有办法在 Firebase Firestore 集合中获取上次创建的文档?我的要求是当用户签名时,我必须在名为“history”的集合中添加一个文档;当用户退出时,我想使用名为“退出”的字段更新该文档;因此,如果我获得最后添加的文档,则很容易更新。有没有办法做到这一点?

firebase angular google-cloud-firestore

3
推荐指数
1
解决办法
1万
查看次数