0
我有一個名爲books的集合,其中包含對象 - isbn,作者,書籍數量(num)
,發佈者等。 剛剛從我的視圖中獲取圖書信息之後,我想檢查圖書的isbn是否已經存在,如果是的話,我想增加書的數量。然而,即使它是同一本書,這個數字也不會增加。有人知道爲什麼NodeJS MongoDb查找重複值並修改增量
var collection = db.collection('books');
var item=collection.findAndModify({
query: { isbn: req.body.isbn13 },
update: { $inc: { num: 1 } },
});
if(item==null)
{add the info to the database}