我想使用set(...)函数,但Firebase-Log显示此函数不可用。
Firebase-Cloud-Function日志:
“在database.collection.doc.collection.doc.set.then.result”中,TypeError: GeoPostLocations.set不是一个函数
const functions = require('firebase-functions');
const functions = require('firebase-functions');
var admin = require('firebase-admin');
var serviceAccount = require('./serviceAccountKey.json');
var GeoFirestore = require('geofirestore').GeoFirestore;
const database = admin.firestore();
const geofirestore = new GeoFirestore(database);
const GeoPostLocations = geofirestore.collection('PostLocations');在我的函数中,我执行以下代码:
return GeoPostLocations.set("DummyIDForTest", [50.312312312, 5.4302434234]]).then(result => {
console.log(result);
return 0;
}).catch(error => {
console.log(error);
return 1;
}); 发布于 2019-01-31 04:34:11
看起来你已经使用了geofirestore版本2的语法编写了一些代码,但是我们现在使用的是v3,应该看起来更像firestore,那么这对你意味着什么呢?
首先,set不是集合可用的函数,但它可用于文档,因此您需要这样做:
return GeoPostLocations.doc('DummyIDForTest').set({
coordinates: new firebase.firestore.GeoPoint(50.312312312, 5.4302434234)
}).then(result => {
console.log(result);
return 0;
}).catch(error => {
console.log(error);
return 1;
});请注意,您必须设置一个对象,而不是数组中的坐标(这不是geofire)。I've included a link to the relevant docs。
https://stackoverflow.com/questions/54445750
复制相似问题