gpt4 book ai didi

node.js - findAndModify mongodb 中的错误 - nodejs - 错误代码 17287

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:38 24 4
gpt4 key购买 nike

我收到以下错误:

MongoError: exception: nextSafe(): { $err: "Can't canonicalize query: B adValue bad sort specification", code: 17287 }

functions.getNextIndex = function(callback){

db.collection('counters').findAndModify(
{_id:'productId'},
{$inc: {sequence_value:1}},

function(err,data){
if(!err)
callback(data);
else
callback(err);
});

}

最佳答案

您的查询中似乎缺少“排序”参数。

尝试如下:

db.collection('counters').findAndModify(
{_id:'productId'},
{_id:'descending'},
{$inc: {sequence_value:1}},

function(err,data){
if(!err)
callback(data);
else
callback(err);
});

在这里查看更多内容: http://docs.mongodb.org/manual/reference/method/db.collection.findAndModify/

关于node.js - findAndModify mongodb 中的错误 - nodejs - 错误代码 17287,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25771052/

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