小编Sta*_*kGU的帖子

类型错误:querySnapshot.forEach 不是函数 - Firebase Cloud Functions

我有一个这样的数据结构:

  • 帖子(收藏)
  • 用户ID(文档)
  • 帖子(收藏)
  • 博士后(文档)

我正在设置一个云函数来根据特定事件更改所有帖子(子集合)文档,为此我使用collectionGroup查询:

我是这样设置的:

exports.changeIsVisibleFieldAfterDay = functions.pubsub
.schedule("every 2 minutes").onRun((context) => {
  const querySnapshot = db.collectionGroup("Posts")
      .where("isVisible", "==", true).get();
  querySnapshot.forEach((doc) => {
    console.log(doc.data());
  });
});
Run Code Online (Sandbox Code Playgroud)

Firebase Log我收到以下错误:

TypeError: querySnapshot.forEach is not a function
Run Code Online (Sandbox Code Playgroud)

网上搜索发现Firebase SDK版本可能有问题,但我的是最新的,我package.json在这里附上文件:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": …
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-platform google-cloud-functions google-cloud-firestore

9
推荐指数
1
解决办法
7504
查看次数

iPhone 正忙:让 iPhone 为开发做好准备 - iOS 15 - Xcode 13

我尝试在装有 iOS 15.0.2 的 iPhone 7 上运行应用程序,但收到此错误:

iPhone is busy: Making iPhone ready for development
Run Code Online (Sandbox Code Playgroud)

我在网上搜索并做了所有告诉我要做的事情,包括:

  1. 干净构建(CMD+SHIFT+K)
  2. 重新启动两台设备
  3. 等待40多分钟

但没有任何改变,我仍然收到相同的加载错误

xcode simulator ios-simulator

8
推荐指数
0
解决办法
468
查看次数

部署错误。构建失败:构建错误详细信息不可用。Firebase 云函数

我重新安装了多次NPMNode在我的电脑。

(npm 版本 7.4.3)

(节点版本 v15.7.0)

我按照以下步骤进行配置Firebase CLI

npm install -g firebase-tools
Run Code Online (Sandbox Code Playgroud)

firebase initfirebase deploy和配置似乎工作正常。

当我打开index.js文件并取消注释股票 helloWorld 函数时,我面临的问题发生了,如下所示:

exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)

我运行firebase deploy并收到此错误

functions[helloWorld(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console.    {urlStuff}


Functions deploy had errors with the following functions:
helloWorld


 To try redeploying those functions, run: …
Run Code Online (Sandbox Code Playgroud)

node.js npm firebase google-cloud-functions

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

使用replaceCurrentItem()时AVPlayer闪烁 - Swift - 以编程方式

我正在以这种方式设置AVPlayer一个UIView

fileprivate func setUpAVPlayer(){
    
    self.cardModel?.urlStrings?.forEach({ (urlString) in
        
        guard let url = URL(string: urlString) else { return }
        let asset = AVAsset(url: url)
        let playerItem = AVPlayerItem(asset: asset, automaticallyLoadedAssetKeys: nil)
        playerItem.addObserver(self, forKeyPath: #keyPath(AVPlayerItem.status), options: [.old, .new], context: nil)
        self.playerItemArray.append(playerItem)
    })
    player = AVPlayer(playerItem: playerItemArray[0])
}
Run Code Online (Sandbox Code Playgroud)

layoutSubviews我布局显示播放器的playerLayer:

let playerLayer = AVPlayerLayer(player: player)
playerLayer.videoGravity = .resizeAspectFill
self.playerView.layer.insertSublayer(playerLayer, at: 0)
playerLayer.frame = playerView.bounds
Run Code Online (Sandbox Code Playgroud)

在发生某个事件时,我更改播放器的当前项目:

fileprivate func goToNextVideo(){
    counter = counter+1
    counter = min(playerItemArray.count-1, counter)
    
    self.player?.replaceCurrentItem(with: self.playerItemArray[self.counter])
    self.player?.seek(to: .zero) …
Run Code Online (Sandbox Code Playgroud)

avfoundation avplayer avplayerlayer swift avplayeritem

5
推荐指数
1
解决办法
1512
查看次数