小编Ren*_*nec的帖子

如何使用firebase发送唯一的注册链接?

我想构建一个应用程序,用户只需在其中注册“邀请”。已经拥有帐户的用户可以向指定的电子邮件地址发送邀请,然后应用程序会发送一封电子邮件,其中包含指向注册的链接,其中有一个令牌,并且只能使用指定的电子邮件地址。

那么首先,如何从 firebase 发送“自动化”电子邮件,其次,如何为 URL 生成唯一的注册令牌?

javascript firebase google-cloud-functions

8
推荐指数
1
解决办法
4539
查看次数

是否可以将数据从 Cloud Firestore 迁移到另一个 NoSQL 数据库?

我正在启动一个新的 Web 应用程序,并且对将 Cloud Firestore 作为我的主要数据库非常感兴趣。但在我将时间投入 Cloud Firestore 之前,我需要一个备份计划。

与 Cassandra 和 Couchbase 等其他 NoSQL 数据库不同,Cloud Firestore 仅作为云服务提供。

选择 Cloud Firestore 意味着您正在进入供应商锁定的世界。

这是否意味着无法将存储在 Cloud Firestore 中的数据移动到另一个 NoSQL 数据库?

在此处读到,从一个 Cloud Firestore 数据库导出的数据可以导入到另一个 Cloud Firestore 数据库中。但我希望能够选择将数据移动到不同的 NoSQL 数据库。

是否可以?如果是这样,您能大致解释一下如何做到这一点吗?

我并不是要求详细回答如何逐步迁移数据。

firebase google-cloud-firestore

8
推荐指数
2
解决办法
7462
查看次数

如何通过与Flutter Cloud Firestore插件中的日期进行比较来获取记录?

在flutter应用程序上工作,我在其中使用Firebase Cloud Firestore存储我的所有文档。我的文档有一个startDateTime字段,其格式如下:

在此处输入图片说明

我想获取其startDateTime大于或等于当前日期的所有记录。这是我的颤振代码来做到这一点...

Firestore.instance.collection("trips")
    .where("trip.createdByUID", isEqualTo: this.userDetails['id'])
    .where("trip.startDateTime", isGreaterThanOrEqualTo: new DateTime.now().toString() )
    .getDocuments().then((string) {
        print('Firestore response111: , ${string.documents.length}');

        string.documents.forEach((doc) => print("Firestore response222: ${doc.data.toString()}" ));
    })
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。无法理解如何使用isGreaterThanOrEqualTo才能正常工作。

需要一些指导。

dart firebase flutter google-cloud-firestore

7
推荐指数
1
解决办法
3720
查看次数

如何从 Cloud Firestore 数据库获取 node.js 中的特定字段值?

如何在节点js中获取那个token_id?

数据库图像

X

Index.js 代码如下,通过此代码,它提供了存储在 user_id 中的所有数据,但我无法仅获取 {token_id} 的特定字段。

const functions = require('firebase-functions');

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

var db = admin.firestore();

exports.sendoNotification = functions.firestore.document('/Users/{user_id}/Notification/{notification_id}').onWrite((change, context) => {


  const user_id = context.params.user_id;
  const notification_id = context.params.notification_id;

  console.log('We have a notification from : ', user_id);
  
  
var cityRef = db.collection('Users').doc(user_id);
var getDoc = cityRef.get()
    .then(doc => {
      if (!doc.exists) {
        console.log('No such document!');
      } else {
        console.log('Document data:', doc.data());
      }
    })
    .catch(err => {
      console.log('Error getting document', err);

		return Promise.all([getDoc]).then(result => {



			const …
Run Code Online (Sandbox Code Playgroud)

push-notification node.js firebase google-cloud-functions google-cloud-firestore

7
推荐指数
1
解决办法
5730
查看次数

包含数组的firestore组合索引的JSON格式是什么?

我想过滤一个集合(让我们称之为documents)使用array-contains一列(比方说keywords)并按另一列(比方说name)排序.

我能够在firebase控制台中创建这个复合索引,但我只能猜测添加它的格式firestore.indexes.json.

不幸的是,我们无法从控制台下载索引文件.

firebase google-cloud-firestore

7
推荐指数
2
解决办法
944
查看次数

Cloud Firestore中的get()和snapshot()之间的区别

我正在从Firebase的Cloud Firestore中读取一些数据,但是我已经看到了几种方法。我看到的示例使用了get和onSnapshot函数,如下所示:

db.collection("cities").doc("SF")
 .onSnapshot(doc => {
      console.log(doc.data());
 });
Run Code Online (Sandbox Code Playgroud)

或这个

var docRef = db.collection("cities").doc("SF");

docRef.get().then(doc => {
    if (doc.exists) {
         console.log("Document data:", doc.data());
    } else {
         console.log("No such document!");
    }
}).catch(function(error) {
   console.log("Error getting document:", error);
        });
Run Code Online (Sandbox Code Playgroud)

它们之间有什么区别吗?

javascript firebase google-cloud-firestore

7
推荐指数
1
解决办法
2573
查看次数

Firestore-获取子集合的父文档

根据要求我的数据库的屏幕截图我正在使用一个使用以下层次结构的Firestore数据库的应用程序:parent_collection:parent_document:子集合:child_document {字符串名称}使用collectionGroup我已经能够查询子集合中具有特定名称的文档,但是我没有知道如何获取parent_document

 db.collectionGroup("subcollection").whereEqualTo("name", searchText).get()
                .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<QuerySnapshot> task) {
                        if(task.isSuccessful()){
                          //here I want to get the parent id of all results
                        }
                    }
                });
Run Code Online (Sandbox Code Playgroud)

做到这一点的最佳方法是什么?

android firebase google-cloud-firestore

7
推荐指数
1
解决办法
1756
查看次数

Flutter Firestore - 如何从文档字段中的文档引用获取数据?

我正在构建一个具有不同问题类型的自学应用程序。现在,其中一个问题有一个包含文档参考列表的字段:

在此输入图像描述

在 Flutter 中,我有以下代码:

Query<Map<String, dynamic>> questionsRef = firestore
.collection('questions')
.where('lesson_id', isEqualTo: lessonId);

await questionsRef.get().then((snapshot) {
  snapshot.docs.forEach((document) {
    var questionTemp;
    switch (document.data()['question_type']) {


      ....



      case 'cards':
        questionTemp = CardsQuestionModel.fromJson(document.data());
        break;


      ....


    }
    questionTemp.id = document.id;
    questions.add(questionTemp);
  });
});
Run Code Online (Sandbox Code Playgroud)

现在,通过“questionTemp”,我可以访问所有字段(lesson_id、options、question_type 等),但是当涉及“cards”字段时,我如何访问该文档引用中的数据?

有没有办法告诉 firestore.instance 自动从这些引用中获取数据?或者我需要为每个电话重新拨打电话吗?如果是这样,我该怎么做?

感谢您提前的支持!

firebase google-cloud-platform flutter google-cloud-firestore

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

实时数据库 Firebase“全有或全无”事务

有没有办法在 RTDB 中操作事务 API 以进行“批量”写入?(我们目前无法迁移到 Firestore)
我们的问题如下:
当向服务器写入新的“作业”对象时,我们正在执行三个连续的写道:

  1. 使用GeoFire API编写位置键
  2. 写作业
  3. 将作业 ID 连接到创建它的用户

不幸的是,如果其中一个写入失败但前一个写入成功,则会导致系统出现重大错误。
我们正在寻找确保完整性的方法,或者在其中一个写入失败时恢复操作。

transactions firebase firebase-realtime-database

6
推荐指数
2
解决办法
4560
查看次数

过滤 Firebase 数据时,Where() 和 orderBy() 过滤器不能一起工作

我有一个向用户展示艺术作品的提要。我想按用户发布帖子的类别和时间过滤用户帖子,以便该提要的最新帖子更接近页面顶部。我正在使用 firebase 函数来检索此数据。

我有一个 firestore 集合,看起来像这样

 tasks -tasksID- 
                {
                   category: art
                   date: 16 october at 3:00pm
                     images: {
                                0 image1
                                1 image2
                             }
                  }
Run Code Online (Sandbox Code Playgroud)

火力基地功能:

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin'

admin.initializeApp()

export const getFeed = functions.https.onCall(async (req,res) =>{
  const docs = await admin.firestore().collection('tasks').where('category', 
    '==', 'art').orderBy('date', 'desc').limit(20).get()    
    return docs.docs.map(doc => {
    return {
        postID: doc.id,
        ...doc.data()
         }
     }) 
 })
Run Code Online (Sandbox Code Playgroud)

艺术提要打字稿:

artFeed (){    
  const getFeed = this.aff.httpsCallable('getFeed')
  this.ajax = getFeed({}).subscribe(data=> {
    console.log(data)
    this.posts =  data …
Run Code Online (Sandbox Code Playgroud)

firebase typescript google-cloud-platform google-cloud-functions angularfire2

6
推荐指数
1
解决办法
2862
查看次数