MongoDB Studio 3T Practice Set Using Tweets.json Dataset | Realcode4you
- realcode4you
- May 25, 2023
- 3 min read
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}}})


rikvip dạo này thấy nhiều người nhắc nên mình cũng ghé thử cho biết thôi. Mình không đăng ký hay chơi gì cả, chủ yếu xem cách họ làm trang và sắp nội dung ra sao. Lướt qua thì thấy giao diện khá dễ chịu, kiểu chia từng khối thông tin rõ ràng nên đọc nhanh vẫn không bị rối mắt. Có đoạn họ nhấn mạnh chuyện bảo mật với hỗ trợ 24 7, nhìn vậy cũng yên tâm hơn chút dù mình chỉ xem qua. Mình thích cái cảm giác cuộn xuống là gặp các tiêu đề box tách bạch, biết ngay đang ở phần nào chứ không bị dính một mớ chữ dài, mấy khung nội dung nhìn gọn…
I've always been a fan of idle games, the kind you leave running in a browser tab, and https://theplanetclicker.net/ fits that niche well. You understand the mechanics within the first minute, no tutorial wall of text needed. Upgrades feel meaningful early on, each purchase noticeably speeds up progress rather than being a marginal tweak buried in a menu. It doesn't pressure you with intrusive notifications or aggressive monetization, something a lot of browser idle games struggle to avoid. Progress saves reliably between sessions too, which matters for a game built around checking back periodically. Compared to other clickers I've tried, this one balances depth and simplicity nicely without overwhelming new players with too many currencies to track at once.
Iwin là cái tên mình tình cờ bắt gặp khi đang lướt đọc một số bài viết và bình luận trên mạng. Thấy được nhắc đến trong vài cuộc trao đổi nên mình cũng ghé vào xem thử. Mình chỉ tham khảo nhanh giao diện và cách bố trí các nội dung chính, chưa dành nhiều thời gian tìm hiểu chi tiết. Cảm nhận ban đầu là bố cục được sắp xếp khá gọn gàng, các mục hiển thị rõ ràng và thuận tiện để theo dõi. Sau khi xem sơ bộ, mình quay lại tiếp tục với những nội dung đang đọc trước đó.
Mình biết đến nn88 com thông qua những bài chia sẻ của cộng đồng trực tuyến. Vì thấy có nhiều người quan tâm nên mình vào trải nghiệm thử để có góc nhìn riêng. 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
Mình biết đến ga179 city thông qua những bài chia sẻ của cộng đồng trực tuyến. Vì thấy có nhiều người quan tâm nên mình vào trải nghiệm thử để có góc nhìn riêng. 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