我想构建一个应用程序,用户只需在其中注册“邀请”。已经拥有帐户的用户可以向指定的电子邮件地址发送邀请,然后应用程序会发送一封电子邮件,其中包含指向注册的链接,其中有一个令牌,并且只能使用指定的电子邮件地址。
那么首先,如何从 firebase 发送“自动化”电子邮件,其次,如何为 URL 生成唯一的注册令牌?
我正在启动一个新的 Web 应用程序,并且对将 Cloud Firestore 作为我的主要数据库非常感兴趣。但在我将时间投入 Cloud Firestore 之前,我需要一个备份计划。
与 Cassandra 和 Couchbase 等其他 NoSQL 数据库不同,Cloud Firestore 仅作为云服务提供。
选择 Cloud Firestore 意味着您正在进入供应商锁定的世界。
这是否意味着无法将存储在 Cloud Firestore 中的数据移动到另一个 NoSQL 数据库?
我在此处读到,从一个 Cloud Firestore 数据库导出的数据可以导入到另一个 Cloud Firestore 数据库中。但我希望能够选择将数据移动到不同的 NoSQL 数据库。
是否可以?如果是这样,您能大致解释一下如何做到这一点吗?
我并不是要求详细回答如何逐步迁移数据。
在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才能正常工作。
需要一些指导。
如何在节点js中获取那个token_id?
数据库图像
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
我想过滤一个集合(让我们称之为documents)使用array-contains一列(比方说keywords)并按另一列(比方说name)排序.
我能够在firebase控制台中创建这个复合索引,但我只能猜测添加它的格式firestore.indexes.json.
不幸的是,我们无法从控制台下载索引文件.
我正在从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)
它们之间有什么区别吗?
我正在使用一个使用以下层次结构的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)
做到这一点的最佳方法是什么?
我正在构建一个具有不同问题类型的自学应用程序。现在,其中一个问题有一个包含文档参考列表的字段:
在 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
有没有办法在 RTDB 中操作事务 API 以进行“批量”写入?(我们目前无法迁移到 Firestore)
我们的问题如下:
当向服务器写入新的“作业”对象时,我们正在执行三个连续的写道:
不幸的是,如果其中一个写入失败但前一个写入成功,则会导致系统出现重大错误。
我们正在寻找确保完整性的方法,或者在其中一个写入失败时恢复操作。
我有一个向用户展示艺术作品的提要。我想按用户发布帖子的类别和时间过滤用户帖子,以便该提要的最新帖子更接近页面顶部。我正在使用 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
firebase ×10
flutter ×2
javascript ×2
android ×1
angularfire2 ×1
dart ×1
node.js ×1
transactions ×1
typescript ×1