Skip to content

Commit

Permalink
fix data structure
Browse files Browse the repository at this point in the history
Signed-off-by: Peng Xiao <[email protected]>
  • Loading branch information
xiaopeng163 committed May 5, 2019
1 parent 7127e43 commit ac5491a
Show file tree
Hide file tree
Showing 26 changed files with 371,448 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,54 @@
Udemy本人更多课程优惠折扣购买地址

https://github.com/udemy-course/Promotion



## 课程资料


### 第三章


JSON数据结构: https://github.com/udemy-course/mongodb-cn/blob/master/chapter3/employee.json

查找和更新 https://github.com/udemy-course/mongodb-cn/blob/master/chapter3/employee_1.json

Document的嵌套 https://github.com/udemy-course/mongodb-cn/blob/master/chapter3/employee_2.json

### 第四章

MongoDB的Python驱动演示 https://github.com/udemy-course/mongodb-cn/blob/master/chapter4/test.py

### 第五章

一对一关系 https://github.com/udemy-course/mongodb-cn/blob/master/chapter5/one-one.json


一对多关系的聚合Aggregation https://github.com/udemy-course/mongodb-cn/blob/master/chapter5/aggregation.json

### 第六章

逻辑和比较操作符练习 https://github.com/udemy-course/mongodb-cn/blob/master/chapter6/movie.json

元素相关操作符 https://docs.mongodb.com/manual/reference/operator/query-element/

Array相关的操作符 https://github.com/udemy-course/mongodb-cn/blob/master/chapter6/array.json

updateOne,updateMany,$set回顾 https://github.com/udemy-course/mongodb-cn/blob/master/chapter6/people.json

### 第七章

单一字段的index https://github.com/udemy-course/mongodb-cn/blob/master/chapter7/index.json

使用unique index唯一值索引 https://github.com/udemy-course/mongodb-cn/blob/master/chapter7/people.json

### 第八章

寻找附近的餐厅 https://github.com/udemy-course/mongodb-cn/blob/master/chapter8/restaurant.json

判断是否在某一个区域内 https://github.com/udemy-course/mongodb-cn/blob/master/chapter8/neighborhood.json


### 第九章

14 changes: 14 additions & 0 deletions chapter10/add-admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
db.createUser(
{
user : "admin",
pwd : "admin",
roles: [
{
role : "readWrite", db : "admin"},
{
role: "userAdminAnyDatabase",
db : "admin"
}
]
}
)
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions chapter13/generate_shard_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import random
import string

res = []
min_char = 100
max_char = 200
allchar = string.ascii_letters + string.punctuation + string.digits


for i in range(100000):
tmp = {}
tmp['testkey'] = random.randint(1, 10000)
tmp['testtext'] = "".join(random.choice(allchar) for x in range(random.randint(min_char, max_char)))
res.append(tmp)

f = open('shard_data.json', 'w')
import json
json.dump(res, f)
f.close()
File renamed without changes.
Binary file added chapter13/shard_data.json.zip
Binary file not shown.
56 changes: 56 additions & 0 deletions chapter5/aggregation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
db.dropDatabase()

db.customer.insertMany(
[
{
"_id": 1,
"name": "John Cart",
"email": "[email protected]",
"phone": 12345,
"orders": [1, 2, 3]
},
{
"_id": 2,
"name": "Arber Su",
"email": "[email protected]",
"phone": 56789,
"orders": [4, 5]
}
])

db.order.insertMany(
[
{
"_id": 1,
"date": "2018-12-10",
"product": "book",
"cost": 19.99
},
{
"_id": 2,
"date": "2018-12-13",
"product": "book",
"cost": 39.99
},
{
"_id": 3,
"date": "2018-12-22",
"product": "computer",
"cost": 2899
},
{
"_id": 4,
"date": "2018-12-01",
"product": "book",
"cost": 19.99
},
{
"_id":5,
"date": "2018-12-29",
"product": "computer",
"cost": 2899
}
]
)

db.customer.aggregate([{$lookup: {from: "order", localField:"orders",foreignField: "_id", as: "order_details"}}]).pretty()
17 changes: 17 additions & 0 deletions chapter5/one-one.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"_id": 1,
"name": "John Cart",
"email": "[email protected]",
"phone": 12345,
"address": 1
}

{
"_id": 1,
"city": "Shanghai",
"street": "aaaaa",
"building": 1,
"unit": 2,
"room": 1021
}

34 changes: 34 additions & 0 deletions chapter6/array.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "Jack",
"age": 27,
"hobby": [
{
"type": "Movie",
"rating": 3
},
{
"type": "Sports",
"rating": 6
}
]
},
{
"name": "Mark",
"age": 25,
"hobby": [
{
"type": "Movie",
"rating": 2
},
{
"type": "Cook",
"rating": 5
},
{
"type": "Music",
"rating": 4
}
]
}
]
File renamed without changes.
34 changes: 34 additions & 0 deletions chapter6/people.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "Jack",
"age": 27,
"hobby": [
{
"type": "Movie",
"rating": 3
},
{
"type": "Sports",
"rating": 6
}
]
},
{
"name": "Mark",
"age": 25,
"hobby": [
{
"type": "Movie",
"rating": 2
},
{
"type": "Cook",
"rating": 5
},
{
"type": "Music",
"rating": 4
}
]
}
]
Loading

0 comments on commit ac5491a

Please sign in to comment.