MongoDB Studio 3T Practice Set Using Tweets.json Dataset | Realcode4you
Install MongoDB and Studio 3T on your computer, create a new database with a name and import 'Tweets.json' (available on iLearn) as a collection. Then complete the following exercises.

Exercise
1. Insert 2 new Tweets to the collection.
2. Write a MongoDB query that returns all the Tweets.
3. Write a MongoDB query to find one of your Tweets with user’s name: "user 30".
4. Update two Tweets to have two tags called “My first tag” and “My second tag” respectively. Show two ways to do this. Do the first one using update() and do the second one using save(). Hint: for save(), you might want to query the object, store it in a variable first; then update it and save the update.
5. Write a MongoDB query to retrieve all documents from the Tweets collection where user name equals either "user 30" or "user 40".
6. Write a MongoDB query to retrieve all documents from the Tweets collection where user screen_name is "Twitter User" and user location is "Internet". (Specify AND Conditions)
7. Write a MongoDB query to retrieve all documents from the Tweets collection where user screen_name is "Twitter User" or user url is "user URL". (Specify OR Conditions)
8. Write a MongoDB query to retrieve all documents from the Tweets collection where user id is not 224499494502
Solution
1. Insert 2 new Tweets to the collection.
A 1.
Solution 1:
//Tweet 1
db.tweets.insert(
{
"created_at": "Thu Apr 06 15:24:15 +0000 2020",
"id_str": "1850006245121695744",
"text": "Have a nice day",
"user": {
"id": NumberLong(2244456599494501),
"name": "user 01",
"screen_name": "Twitter User",
"location": "Internet",
"url": "user URL",
"description": "user description"
},
"place": {
},
"entities": {
"hashtags": [
],
"urls": [{
"url": "twt url sample",
"unwound": {
"url": "url sample",
"title": "web page title"
}
}],
"user_mentions": [
]
}
})//Tweet 2
db.tweets.insert(
{
"created_at": "Thu Apr 06 15:24:15 +0000 2020",
"id_str": "1850006245121695744",
"text": "Good Morning",
"user": {
"id": NumberLong(2244456599494501),
"name": "user 01",
"screen_name": "Twitter User",
"location": "Internet",
"url": "user URL",
"description": "user description"
},
"place": {
},
"entities": {
"hashtags": [
],
"urls": [{
"url": "twt url sample",
"unwound": {
"url": "url sample",
"title": "web page title"
}
}],
"user_mentions": [
]
}
})Solution 2:
db.tweets.insert(
[{
"created_at": "Thu Apr 06 15:24:15 +0000 2020",
"id_str": "1850006245121695744",
"text": "Hi",
"user": {
"id": 2244456599494501,
"name": "user 01",
"screen_name": "Twitter User",
"location": "Internet",
"url": "user URL",
"description": "user description"
},
"place": {
},
"entities": {
"hashtags": [
],
"urls": [{
"url": "twt url sample",
"unwound": {
"url": "url sample",
"title": "web page title"
}
}],
"user_mentions": [
]
}
},
{
"created_at": "Thu Apr 06 15:24:17 +0000 2020",
"id_str": "8510006245121695744",
"text": "Welcome",
"user": {
"id": 224499494503,
"name": "user 03",
"screen_name": "Twitter User",
"location": "Internet",
"url": "user URL",
"description": "user description"
},
"place": {
},
"entities": {
"hashtags": [
],
"urls": [{
"url": "twt url sample",
"unwound": {
"url": "url sample",
"title": "web page title"
}
}],
"user_mentions": [
]
}
}
]
)
2. Write a MongoDB query that returns all the Tweets.
db.Tweets.find() 3. Write a MongoDB query to find one of your Tweets with user’s name: "user 30".
db.Tweets.findOne({"user.name":"user 30"})4. Update two Tweets to have two tags called “My first tag” and “My second tag” respectively. Show two ways to do this. Do the first one using update() and do the second one using save(). Hint: for save(), you might want to query the object, store it in a variable first; then update it and save the update.
Solution 1 (update ()):
db.Tweets.update({"user.name":"user 30"}, {$set:{"tag":"My first tag"}})
db.Tweets.update({"user.name":"user 40"}, {$set:{"tag":"My second tag"}}) Solution 2 (save ()):
var tweet_user30 = db.Tweets.findOne({"user.name":"user 30"})
tweet_user30["tag"] = "My first tag"
db.Tweets.save(tweet_user30)
var tweet_user40 = db.Tweets.findOne({"user.name":"user 40"})
tweet_user40["tag"] = "My second tag"
db.Tweets.save(tweet_user40)5. Write a MongoDB query to retrieve all documents from the Tweets collection where user name equals either "user 30" or "user 40".
db.Tweets.find({"user.name":{ $in: [ "user 30", "user 40" ] } })6. Write a MongoDB query to retrieve all documents from the Tweets collection where user screen_name is "Twitter User" and user location is "Internet". (Specify AND Conditions)
db.Tweets.find({$and: [{"user.screen_name": "Twitter User"}, {"user.location":"Internet"}]})7. Write a MongoDB query to retrieve all documents from the Tweets collection where user screen_name is "Twitter User" or user url is "user URL". (Specify OR Conditions)
db.Tweets.find({ $or: [{"user.screen_name": "Twitter User"}, {"user.url":"user URL"}]})8. Write a MongoDB query to retrieve all documents from the Tweets collection where user id is not 224499494502.
Solution 1:
db.Tweets.find({"user.id":{$ne:224499494502}})Solution 2:
db.Tweets.find({"user.id":{$not:{$eq:224499494502}}})


SutbongTV live mình cũng kiểu nghe người ta nhắc nên bấm vào xem thử cho biết thôi. Không có ngồi đọc hết nội dung đâu, chủ yếu lướt giao diện với cách họ chia phần. Thấy trang làm khá dễ theo dõi, mấy tiêu đề đặt thẳng thắn nên nhìn cái là đoán được chủ đề đang nói gì. Có đoạn giới thiệu viết ngắn gọn, nói họ kết hợp sáng tạo với chức năng trong kiến trúc nên mình đọc lướt vẫn nắm ý. Mình thích kiểu cuộn xuống là từng khối nội dung tách riêng, không bị nhồi chữ, nhìn đỡ mệt mắt. Phần điều hướng cũng ổn, chuyển qua lại không bị rối, nhất là heading “Cam kết…
Trong quá trình đọc các thảo luận, mình có để ý thấy qs88cv.com com được nhắc qua nên thử vào xem cho biết. Mình chỉ xem nhanh tổng thể chứ chưa tìm hiểu sâu, nhưng cảm giác ban đầu là cách trình bày khá thoáng, bố cục rõ ràng, nhìn vào không bị rối mắt.
cakhiatvtrựctiếp mình có ghé vào xem thử sau khi thấy xuất hiện trong một vài nội dung trên mạng, chủ yếu để tham khảo cách họ thiết kế giao diện và tổ chức thông tin. Dù chỉ lướt nhanh nhưng có thể nhận ra bố cục được chia khá rõ, các phần nội dung hiển thị tách bạch nên nhìn không bị rối. Thanh điều hướng bố trí dễ thấy, giúp việc chuyển qua lại giữa các mục diễn ra khá nhanh. Khi dùng trên điện thoại, trang vẫn hoạt động ổn định, thao tác mượt. Tổng thể mang lại cảm giác dễ tiếp cận.
789win mình tình cờ bắt gặp khi đang lướt xem một số nội dung trên mạng và chú ý đến phần thông tin được nhắc bên dưới. Mình ghé qua xem sơ giao diện, thấy các danh mục được phân chia thành từng khu vực riêng nên khá dễ quan sát. Nội dung được sắp xếp theo từng phần, các mục chính có vị trí tương đối dễ nhận biết, giúp người xem hình dung cấu trúc chung của website. Nhìn tổng thể, bố cục được trình bày khá gọn, các khu vực nội dung tách biệt nên dễ theo dõi khi lướt qua.
sx88 được nhắc đến khi đang đọc một vài chia sẻ trên mạng nên cũng mở vào xem thử. Mình không dành nhiều thời gian khám phá hết các nội dung, chủ yếu xem cách họ bố trí giao diện và phân chia các chuyên mục. Ấn tượng đầu tiên là bố cục được làm khá mạch lạc, các phần thông tin được sắp xếp theo từng nhóm nên nhìn tổng thể khá dễ theo dõi và không tạo cảm giác quá nhiều nội dung dồn vào một chỗ. Mình cũng để ý việc di chuyển giữa các mục khá thuận tiện nhờ thanh điều hướng được bố trí rõ ràng.