我正在尝试重建使用Firebase Cloud Functions和Firestore的Web应用程序示例。部署功能时,出现以下错误:
src/index.ts:45:18 - error TS2532: Object is possibly 'undefined'.
45 const data = change.after.data();
Run Code Online (Sandbox Code Playgroud)
这是功能:
export const archiveChat = functions.firestore
.document("chats/{chatId}")
.onUpdate(change => {
const data = change.after.data();
const maxLen = 100;
const msgLen = data.messages.length;
const charLen = JSON.stringify(data).length;
const batch = db.batch();
if (charLen >= 10000 || msgLen >= maxLen) {
// Always delete at least 1 message
const deleteCount = msgLen - maxLen <= 0 ? 1 : msgLen - maxLen
data.messages.splice(0, deleteCount);
const ref …
Run Code Online (Sandbox Code Playgroud) firebase typescript google-cloud-functions google-cloud-firestore
我有一个流构建器在监听 Firestore,它有点工作。主要问题是streambuilder不断重建(如果它不花费我额外的读取,那么不用担心,但如果它这样做了,那么这是一个我假设它确实存在的问题)。当主页第一次构建时,当我转到另一个页面时,它会再次构建,当我弹回主页时,它会第三次重建。
代码:
class _RequestsListState extends State<RequestsList> with AutomaticKeepAliveClientMixin {
final Map<String, List<Post>> posts = {};
final List<String> postsUserIDs = [];
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
print('RequestsList');
User cUser = InheritedUser.of(context).user;
return StreamBuilder<List<Post>>(
initialData: cUser.posts,
stream: APIs().posts.auPostsStream(cUserID: cUser.userID),
builder: (context, snap) {
if (snap.hasError) {
print('AUPostsList.dart StreamBuilder Error: ${snap.error}');
return null;
} else {
print('POSTS LENGTH');
print(snap.connectionState);
print(cUser.posts.length);
this.posts.clear();
this.postsUserIDs.clear();
snap.data.forEach((post) {
if (this.posts[post.user.documentID] == null) {
this.posts[post.user.documentID] = [post];
} else { …
Run Code Online (Sandbox Code Playgroud) 我正在运行聊天应用程序代码,它给了我身份验证运行时错误。错误信息如下所示。我尝试了几件事,但没有任何结果,如果您需要其他与代码相关的信息,请告诉我。
提前致谢
代码是 AppDelegate.Swift 文件
internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Auth.auth().signInAnonymously { (authUser, error) in
guard Auth.auth().currentUser != nil else {
print(error!)
abort()
}
self.uid = Auth.auth().currentUser!.uid
UserDefaults.standard.set(Auth.auth().currentUser!.uid, forKey: "uid")
let user = User(id: Auth.auth().currentUser!.uid, name: "??")
UserRepository.shared.save(user)
}
return true
}
Run Code Online (Sandbox Code Playgroud)
错误信息
Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details …
Run Code Online (Sandbox Code Playgroud) ios firebase swift firebase-authentication google-cloud-firestore
我在新计算机上设置了新环境并安装了 magento cloud cli。并尝试通过运行登录云帐户,magento-cloud login
但http://127.0.0.1:5000
始终返回
链接This site can’t be reached
所以我做了替代登录并运行此命令:magento-cloud auth:password-login
登录到我的云帐户,我将无法登录。它总是返回登录失败。请检查您的凭据。
Please log in using your Magento Cloud account.
Your email address or username: myemail@company.com
Your password:
Login failed. Please check your credentials.
Forgot your password? Or don't have a password yet?
Visit:https://accounts.magento.cloud/user/password
Run Code Online (Sandbox Code Playgroud)
我想知道为什么它总是失败有什么我错过的吗?我已经尝试了很多次,我真的很确定我输入的凭据是正确的。我也遵循了环境设置的 magento 文档:https : //devdocs.magento.com/guides/v2.2/cloud/setup/first-time-setup.html
我正在尝试在我的应用中使用Realm。我正在保存数据,一切都很好,但是当我最终想要读取数据并将其发送到Firebase时,我遇到了错误。
@IBAction func registerButtonTapped(sender: BouncingButton) {
if !monday.isEmpty() && !tuesday.isEmpty() && !wednesday.isEmpty() && !thursday.isEmpty() && !friday.isEmpty() && !saturday.isEmpty() && !sunday.isEmpty() {
Constants.ActivityIndicator.startActivity()
self.days.setObject(["open":monday.open,"close":monday.close], forKey: "Monday")
self.days.setObject(["open":tuesday.open,"close":tuesday.close], forKey: "Tuesday")
self.days.setObject(["open":wednesday.open,"close":wednesday.close], forKey: "Wednesday")
self.days.setObject(["open":thursday.open,"close":thursday.close], forKey: "Thursday")
self.days.setObject(["open":friday.open,"close":friday.close], forKey: "Friday")
self.days.setObject(["open":saturday.open,"close":saturday.close], forKey: "Saturday")
self.days.setObject(["open":sunday.open,"close":sunday.close], forKey: "Sunday")
let email = Constants.clubRegisterForm.email
let password = Constants.clubRegisterForm.password
let credential = FIREmailPasswordAuthProvider.credentialWithEmail(email, password: password)
Constants.FirebaseAPI.Auth?.createUserWithEmail(email, password: password, completion: { (user, error) in
if error != nil {
Constants.ActivityIndicator.stopActivity()
Constants.Alerts.checkErrors(error!)
} else {
let changeRequest = user?.profileChangeRequest()
changeRequest?.photoURL …
Run Code Online (Sandbox Code Playgroud) 我正在尝试结合 Spring-Security 来了解有关 Spring-Websocket 的更多信息,并且正在尝试Spring 文档中的示例。
在创建我的课程WebSecurityConfig
并从AbstractWebSocketMessageBrokerConfigurer
我那里扩展后,我被告知AbstractWebSocketMessageBrokerConfigurer
已弃用。
我试图找出是否有其他方法可以将 Spring-Security 与 Spring-Websocket 结合使用,但找不到相关内容。
所以,我的问题是我应该继续使用AbstractWebSocketMessageBrokerConfigurer
还是有另一种方法将 Spring-Security 与 Spring-Websocket 结合起来?
这是我在测试项目中实现的示例。它似乎对你有用,但在AbstractWebSocketMessageBrokerConfigurer
弃用之前不应该有 Spring 的替代方案吗?
@Configuration
public class WebSocketSecurityConfig extends AbstractWebSocketMessageBrokerConfigurer {
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages.simpDestMatchers("/user/*").authenticated();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在查询特定文档的集合,并尝试从 FirebaseFirestore.QuerySnapshot 类型的查询结果中获取文档 ID。
我的实际查询如下所示(我正在使用 async/await):
result = await db.collection("chatrooms").where("userA", "==", req.body.userA)
.where("userB", "==", req.body.userB).limit(1).get();
Run Code Online (Sandbox Code Playgroud)
我尝试过:
await result.docs.map(doc => {
return doc.id
})
Run Code Online (Sandbox Code Playgroud)
但这给了我一个undefined
支持。
我究竟做错了什么?
Firestore中有什么方法可以获取单个数组中的数据列表,例如..在RealTimeDatabase中,我们通过调用单个值而不是使用ForEachLoop来获取Data数组...例如,在realtimeDatabase中,我们通过以下方式获取值:
var PersonObjArrays : [Person] = [ ] ()
Database.database().
reference.child("personFullname").observe( .childAdded.
, with : { (snapshot) in
let snapShotValue = snapshot.value
let firstname = snapShotValue["firstname"] as! String
let lastname = snapShotValue["lastname"] as! String
let personObj = Person( firstname ,lastname)
self.messageArray.append(personObj)
Run Code Online (Sandbox Code Playgroud)
但是在Firestore中,我们必须使用ForLoop .....例如,在Firestore中,我们使用了
FireStore.firestore()
.collection("personFullname").
getDocuments { (snapshot , error ) in
for document in snaphot.document {
let data = document.data( )
let firstName = data["firstname"] as! String
let lastnamNname = data["lastname"] as! String
let personObj2 = Person( firstName , …
Run Code Online (Sandbox Code Playgroud) algorithm firebase swift firebase-realtime-database google-cloud-firestore
一开始,我们已将自定义域链接到 Firebase 托管,以使用此域创建动态链接。今天,我们想删除它。从 firebase 托管中删除连接的域非常简单,但它仍然保留在动态链接部分的 url 前缀列表中。有一个删除按钮,但它被禁用(我不知道为什么)。
有人找到了解决方案吗?
此外,我试图删除之前创建的链接,所以我点击了存档按钮,但实际上该链接仍然处于活动状态(只是不再列在动态链接列表中)。“不活跃”需要时间吗?
先感谢您
最近我在 Angular 中使用了一个带有 else 块的*ngIf
指令,并且想知道为什么在Angular 文档中的示例使用分号 ( <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
) ,因为这似乎也可以在没有分号的情况下工作。
不使用分号有什么副作用吗?或者这只是一种更简洁的编码方式?