2017-09-23 1 views
0

これはおそらく非常に単純な間違いですが、私はそれを見つけることができません。この単純なクエリを実行している:私はモンゴのv3.2.6とRobomongo 1.0で動作

Error: field names cannot start with $ [$set] : [email protected]/mongo/shell/collection.js:185:1 [email protected]/mongo/shell/collection.js:189:13 [email protected]/mongo/shell/collection.js:189:13 [email protected]/mongo/shell/collection.js:416:9 Bulk/[email protected]/mongo/shell/bulk_api.js:675:9 [email protected]/mongo/shell/collection.js:483:13 @(shell):1:1

db.getCollection('thoughts').update(
    {space: {type: 'list'}}, 
    {space: {type: {$set: 'arrangement'}}} 
); 

私はこのエラーを取得します。

アイデア?

答えて

1

はこれを試してみてください:複数のドキュメントを更新するために、あなたは真のmultiオプションを設定する必要があること

db.thoughts.update(
    { "space.type": "list" }, 
    { $set: { "space.type": "arrangement" } } 
); 

お知らせ:

db.thoughts.update(
    { "space.type": "list" }, 
    { $set: { "space.type": "arrangement" } }, 
    { multi: true } 
); 
+0

をはい、それが、おかげで動作します!私が書いた文章は、「反応アドオン更新」で働いていて、私を混乱させました。なぜなら、これらの構文は非常に似ているからです。 –

+0

偉大なことを聞​​いて:) – nadavvadan

関連する問題