使用查询

时间:2017-03-14 18:51:11

标签: javascript mongodb

我试图编写一个简单的脚本,其中有一组数字,用于更新在球衣对象中具有该特定数字的文档,以及该文档在球衣内的赞助商对象将被更新。下面我有一个名为"运动员"的集合的钥匙,在一个名为" sports"的数据库中,而不是我到目前为止的脚本。更改数组将是一个数字列表,而不是我想要使用它并将赞助商字段更新为" Nike"。现在我正在收到此错误,但我一直在添加/删除括号,但目前无济于事。我也很好奇我是否应该在某些地方使用单引号或双引号,因为我已经查看过示例并且已经看过两者。

SyntaxError: Unexpected token {

firstName - String
lastName - String
jersey - Object
   number - String 
   sponsor - String

注意:每个文档在“球衣”对象中都有唯一的“数字”

db = db.getSiblingDB('sports');

var changes = [
  "23",
  "8"
];

for(var i = 0; i < changes.length; i++) {
    db.athletes.update({
      "jersey": {
      "number": changes[i],
    },
  }
  {'$set': {"sponsor": 'Nike'} }
 );}

1 个答案:

答案 0 :(得分:0)

命令:

--> the user launch the app, the app is say you have updates
--> the user select yes or no to update or not to update
--> if select **no** the user don't update 
--> launch the app again the App say we have download your updates you 
    want to install now **YES** or **NO**

--> if select **yes** the app start installing the myApp-setup-v2.5.7
相关问题