我在Firebase文档中找不到解决方案.
我想在functions.https.onCall本地测试我的功能.是否可以使用shell或以某种方式将我的客户端(启用firebase SDK)连接到本地服务器?
我想避免每次只是为了测试对我的onCall功能的更改而进行部署.
功能:
exports.myFunction = functions.https.onCall((data, context) => {
// Do something
});
Run Code Online (Sandbox Code Playgroud)
客户:
const message = { message: 'Hello.' };
firebase.functions().httpsCallable('myFunction')(message)
.then(result => {
// Do something //
})
.catch(error => {
// Error handler //
});
Run Code Online (Sandbox Code Playgroud) 我知道在react-native中我们可以__DEV__用来确定我们是在运行调试版本还是发布版本.
我staging在Xcode中创建了一个新的构建配置(用于测试版),并希望在js代码中检测这个env.我怎样才能做到这一点?
目标是让我的应用程序连接到debug构建中的localhost api,构建中的dev api和staging构建中的生产api release.
为了让事情更简单,假设应用程序只有 2 个实体:theuser和 the post,它们是用户创建的内容。
用户可以做三件事:
我的问题是:如何posts根据作者是否被我取消关注来查询?
users/{userId}
- userId
posts/{postId}
- author <userId>
- content
unfollows/{userId}
- userId
- unfollowedUserId
likes/{postId_userId}
- postId
- userId
dislikes/{postId_userId}
- postId
- userId
Run Code Online (Sandbox Code Playgroud)
查询帖子:
// get all userIds that I unfollow
const unfollows = collection('unfollows').where('userId', '==', 'myUserId');
Run Code Online (Sandbox Code Playgroud)
但是后来我不知道如何有效地posts使用unfollows用户 id 数组进行查询。
// This doesn't seem correct and
// I don't know how to write the `where` filters programmatically:
// assume …Run Code Online (Sandbox Code Playgroud) 我的目标
我只想允许用户更新其他人的用户文档中的特定字段。
我的用户文档
/* BEFORE */
{
id: 'uid1',
profile: { /* a map of personal info */ },
connectedUsers: {
uid2: true,
uid3: true,
}
}
/* AFTER */
{
id: 'uid1',
profile: { /* a map of personal info */ },
connectedUsers: {
uid2: true,
uid3: true,
uid4: true, // <--- added.
}
}
Run Code Online (Sandbox Code Playgroud)
请求
const selfUserId = 'uid4';
db.runTransaction(function(transaction) {
return transaction.update(userDocRef).then(function(userDoc) {
if (!userDoc.exists) { throw "Document does not exist!"; }
transaction.update(userDocRef, 'connectedUsers.${selfUserId}', true);
});
} …Run Code Online (Sandbox Code Playgroud)