【问题标题】:firebase checking document existsfirebase 检查文件是否存在
【发布时间】:2020-08-30 14:56:41
【问题描述】:

来自不和谐的 js

client.on('message',msg => {
    if (msg.channel.type === "dm") return;
    let ticket_number = msg.channel.name.slice(5).toUpperCase();
    db.collection('tickets').doc(ticket_number).get().then((database) =>{
        if(!database.exists) return
            db.collection('tickets').doc(ticket_number).update({
                "ticket_log":`${database.data().ticket_log} \n [${msg.author.tag}] : ${msg}`
            }) 
        
    })
});

一直报错

F:\TP_Forum\node_modules@google-cloud\firestore\build\src\path.js:403 抛出新错误(${validate_1.invalidArgumentMessage(arg, 'resource path')} Path must be a non-empty string.);

Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string.
    at Object.validateResourcePath (F:\TP_Forum\node_modules\@google-cloud\firestore\build\src\path.js:403:15)
    at CollectionReference.doc (F:\TP_Forum\node_modules\@google-cloud\firestore\build\src\reference.js:1988:20)
    at Client.<anonymous> (F:\TP_Forum\index.js:61:30)
    at Client.emit (events.js:327:22)
    at MessageCreateAction.handle (F:\TP_Forum\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (F:\TP_Forum\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (F:\TP_Forum\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (F:\TP_Forum\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
    at WebSocketShard.onMessage (F:\TP_Forum\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
    at WebSocket.onMessage (F:\TP_Forum\node_modules\ws\lib\event-target.js:125:16)

【问题讨论】:

    标签: javascript node.js firebase google-cloud-firestore discord.js


    【解决方案1】:

    几乎可以肯定ticket_number 是一个空字符串。在文档路径中使用字符串之前,您应该在代码中检查这一点。

    【讨论】:

      猜你喜欢
      • 2022-01-24
      • 2021-02-26
      • 2016-10-11
      • 2021-12-25
      • 1970-01-01
      相关资源
      最近更新 更多