2012-04-28 9 views
5

私はnode.jsとmongodbを学んでいます。私は私のアプリでmongoskinモジュールを使用していますが、私は機能する "upsert"機能を得ることができません。Mongoskin(node.jsとmongodb)でアップサート

私はgithubの(むしろ不透明な)mongoskinガイドを読みました。これまでに試したことは次のとおりです。

// this works. there's an insert then an update. The final "x" is "XX". 
db.collection("stuff").insert({a:"A"}, {x:"X"}); 
db.collection("stuff").update({a:"A"}, {x:"XX"}); 

// this does NOT work. I thought it would do an upsert, but nothing. 
db.collection("stuff").update({b:"B"}, {y:"YY"}, true); 

"存在しない場合は更新または挿入する"機能をどのように作成できますか?私はそれを試してみましたが、ここではドキュメントに応じていませんでした

答えて

関連する問題