User Tools

Site Tools


staff:courses:no_sql_introduction:mongo_query_across_levels

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
staff:courses:no_sql_introduction:mongo_query_across_levels [2016/11/28 12:09]
mark created
staff:courses:no_sql_introduction:mongo_query_across_levels [2022/12/10 09:08] (current)
Line 1: Line 1:
 Задача:​ в БД с данными о видах и конкретных особях животных найти тех, кто питается одинаковым кормом. Исходные данные:​ Задача:​ в БД с данными о видах и конкретных особях животных найти тех, кто питается одинаковым кормом. Исходные данные:​
  
-//db.animals.insert({animal_type:"​l1",​ individuals:​ [ {name: "",​ text: "",​ feed: [1, 2] }, {name: "",​ text: "",​ feed: [3,4] }]})+<code javascript>​db.animals.insert({animal_type:"​l1",​ individuals:​ [ {name: "",​ text: "",​ feed: [1, 2] }, {name: "",​ text: "",​ feed: [3,4] }]})
 db.animals.insert({animal_type:"​l2",​ individuals:​ [ {name: "",​ text: "",​ feed: [1, 2] }, {name: "",​ text: "",​ feed: [2] }]}) db.animals.insert({animal_type:"​l2",​ individuals:​ [ {name: "",​ text: "",​ feed: [1, 2] }, {name: "",​ text: "",​ feed: [2] }]})
-db.animals.insert({animal_type:"​l3",​ individuals:​ [ {name: "",​ text: "",​ feed: [1, 2] }, {name: "",​ text: "",​ feed: [3] }]})//+db.animals.insert({animal_type:"​l3",​ individuals:​ [ {name: "",​ text: "",​ feed: [1, 2] }, {name: "",​ text: "",​ feed: [3] }]})</code>
  
 Решение:​ Решение:​
Line 11: Line 11:
 Вывод: Вывод:
  
-//{ "​_id"​ : ObjectId("​5834832075ec6ecba9a62c11"​),​ "​animal_type"​ : "​l1",​ "​individuals"​ : [ { "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 1, 2 ] }, { "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 3, 4 ] } ] } +<code javascript>​ 
-{ "​_id"​ : ObjectId("​5834833975ec6ecba9a62c13"​),​ "​animal_type"​ : "​l3",​ "​individuals"​ : [ { "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 1, 2 ] }, { "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 3 ] } ] }//+{ 
 +  ​"​_id"​ : ObjectId("​5834832075ec6ecba9a62c11"​), ​ 
 +  ​"​animal_type"​ : "​l1", ​ 
 +  ​"​individuals"​ : [  
 +    ​{ "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 1, 2 ] },  
 +    ​{ "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 3, 4 ] }  
 +  ​ 
 +
 + 
 +  ​"​_id"​ : ObjectId("​5834833975ec6ecba9a62c13"​), ​ 
 +  ​"​animal_type"​ : "​l3", ​ 
 +  ​"​individuals"​ : [  
 +    ​{ "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 1, 2 ] },  
 +    ​{ "​name"​ : "",​ "​text"​ : "",​ "​feed"​ : [ 3 ] }  
 +  ​ 
 +} 
 +</code>
staff/courses/no_sql_introduction/mongo_query_across_levels.1480334962.txt.gz · Last modified: 2022/12/10 09:08 (external edit)