gpt4 book ai didi

javascript - 如何提前终止 MongoDb shell 脚本?

转载 作者:IT老高 更新时间:2023-10-28 13:14:45 25 4
gpt4 key购买 nike

写作:

if (...) {
return;
}

在 MongoDb shell 脚本中会报错:SyntaxError: return not in function

我也试过 exit mongo 控制台命令:

if (...) {
exit;
}

但是你得到错误:ReferenceError: exit is not defined

如何提前终止js脚本文件中的执行?

最佳答案

在 mongodb 中,您可以使用文档中的 quit() 函数 here .虽然没有很好地记录,但我做了一个快速测试,可以通过执行 quit(1) 返回一个非零退出代码,这将退出 w/status 1。

关于javascript - 如何提前终止 MongoDb shell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17833663/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com