无法将Firestorage的网址字符串添加到Firestore

时间:2018-08-10 15:21:44

标签: firebase react-native google-cloud-firestore

我在将数据添加到Firestore时遇到问题。如果来自Firestorage的URL引用不在数据集中,那么我可以毫无问题地上传数据。我什至没有问题地将空白文档上传到Firestore。我能够上传大约3个月前的数据,但现在无法正常工作。

dbRef = firebase.firestore().collection('Collection');
      const inputInfo = new GeoFirestore(dbRef);
        inputInfo.add({ 
        coordinates: new firebase.firestore.GeoPoint(this.state.latitude, this.state.longitude),
        mainPhotoURL: this.state.mainPhotoURL,
        address: this.state.address,
        nickName: this.state.nickName,
        firebaseID: this.state.firebaseID,
      }).then((docRef) => {
        console.log(docRef.id); // ID of newly added document
        console.log(docRef);
      }, (error) => {
        console.log('Error: ' + error);
      });de here

如果我取出mainphoto网址,它将上传。如果我将其放入数据集中,则它将不会添加到数据库中。我已经在控制台上记录了mainphoto对象,并且其中包含数据。以前有人遇到过这个问题吗?

1 个答案:

答案 0 :(得分:0)

根据我对documentation的初步阅读,看来您仅将坐标放入了geoFirestore中。使用指向geoFirestore uid的指针,将昵称等元数据放在单独的集合/文档中。

  

GeoFirestore实例用于读取地理位置数据并将其写入   您的Firestore数据库并创建查询。

     
geoFirestore.set({
  'some_key':  { coordinates: new firebase.firestore.GeoPoint(37.79, -122.41)},
  'another_key':  { coordinates: new firebase.firestore.GeoPoint(36.98, -122.56)}
}).then(() => {
  console.log('Provided keys have been added to GeoFirestore');
}, (error) => {
  console.log('Error: ' + error);
});