Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 节点-select()参数无效。必须是字符串或对象_Node.js_Express_Mongoose_Async Await_Cloudinary - Fatal编程技术网

Node.js 节点-select()参数无效。必须是字符串或对象

Node.js 节点-select()参数无效。必须是字符串或对象,node.js,express,mongoose,async-await,cloudinary,Node.js,Express,Mongoose,Async Await,Cloudinary,我正在创建一个网站,用户可以编辑已经存在的帖子,并将自己的图片添加到帖子中。然而,当我上传任何图像时,我收到一个错误。我使用Node、Express、Mongoose和Cloudinary来完成这个任务 以下是用户填写的编辑表单: <div class="row"> <h1 style="text-align: center">Upload photos for: <%= listing.address %></h1> <di

我正在创建一个网站,用户可以编辑已经存在的帖子,并将自己的图片添加到帖子中。然而,当我上传任何图像时,我收到一个错误。我使用Node、Express、Mongoose和Cloudinary来完成这个任务

以下是用户填写的编辑表单:

<div class="row">
    <h1 style="text-align: center">Upload photos for: <%= listing.address %></h1>
    <div style="width: 30%; margin: 25px auto;">
        <form action="/<%= listing._id %>/dashboard?_method=PUT" method="POST" enctype="multipart/form-data">
            <div class="form-group">
                <label for="image">Images</label>
                <input type="file" id="images" name="listing[images]" accept="image/*" multiple required>
            </div>
            <div class="form-group">
                <button class="btn btn-lg btn-primary btn-block">Submit!</button>
            </div>
        </form>
        <a href="/">Go Back</a>
    </div>
</div>
以下是我尝试上载图像时收到的错误:

(node:8048) UnhandledPromiseRejectionWarning: TypeError: Invalid select() argument. Must be string or object.
(node:8048) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8048) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
在“列表”mongoose模型中,我有一个名为“images”的字符串数组,上传的图像URL将存储在该数组中。任何帮助都将不胜感激。提前感谢。

以下是的参数:

  • 要查询的_id的id«Object | String | Number»值
  • [投影]«对象|字符串»要返回的可选字段,请参阅
  • [选项]«对象»可选请参见
  • [回调]«函数»

  • 这就是它给出
    TypeError:Invalid select()参数的原因。必须是字符串或对象。
    当您传递
    upload.array(“列出[图像]”)
    时,它既不是对象也不是字符串。而且,findByID只会返回文档,不会像您尝试的那样进行更新。您需要更新文档。

    哈哈,哇。这真是一个愚蠢的错误。谢谢!
    (node:8048) UnhandledPromiseRejectionWarning: TypeError: Invalid select() argument. Must be string or object.
    (node:8048) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:8048) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.