Mongo数据库查询语法

时间:2018-01-06 13:18:19

标签: json mongodb nosql mongodb-query

我在Mongo数据库表中插入了以下行。

我需要获得执行以下操作的查询 a)意大利队队员的上限数量仅增加10% b)查找包含String" es"

的30岁以上的所有玩家

非常感谢任何帮助。

db.teams.insert({

team_id: "eng1",
date_founded: new Date("Oct 04, 1896"),
 league: "Premier League",
 points: 62,
 name: "Manchester United",
 players: [ { p_id: "Rooney", goal: 85, caps: 125, age: 28 },
          { p_id: "Scholes", goal: 15, caps: 225, age: 28 },
          { p_id: "Giggs", goal: 45, caps: 359, age: 38 } ]
 });

db.teams.insert({

team_id: "spa1",
date_founded: new Date("Oct 04, 1912"),
 league: "La Liga",
 points: 80,
 name: "Barcelona",
 players: [ { p_id: "Messi", goal: 195, caps: 189, age: 30 },
          { p_id: "Valdes", goal: 0, caps: 158, age: 27 },
          { p_id: "Iniesta", goal: 72, caps: 25, age: 31},
          { p_id: "Pique", goal: 9, caps: 201, age: 38 } ]
 });

db.teams.insert({

team_id: "ita3",
date_founded: new Date("Oct 04, 1911"),
 league: "Serie A",
 points: 62,
 name: "AC Milan",
 players: [ { p_id: "Inzaghi", goal: 115, caps: 189, age: 35 },
          { p_id: "Abbiati", goal: 0, caps: 84, age: 24 },
          { p_id: "Van Basten", goal: 123, caps: 104, age: 35 } ]
 });

db.teams.insert({

team_id: "ita4",
date_founded: new Date("Oct 04, 1902"),
 league: "Serie A",
 points: 71,
 name: "Inter Milan",
 players: [ { p_id: "Handanovic", goal: 0, caps: 51, age: 29 },
          { p_id: "Cambiasso", goal: 35, caps: 176, age: 35 },
          { p_id: "Palacio", goal: 78, caps: 75, age: 31 } ]
 });

0 个答案:

没有答案