In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. View the database
Show dbs
two。 Create a runoob database
Use runoob
3. View collections in runoob
Show collections
4. Create address set (address_home,address_office)
Db.createCollection ("address_home")
Db.createCollection ("address_office")
5. View created collections
Show collections
6. Add data to the home (address_home) address set and the address_office address set, respectively
Db.address_home.insertOne ({
'name':'home address'
'province':'jiangsu'
'city':'xuzhou'
})
View address_home data
Db.address_home.find () .pretty ()
Db.address_office.insertOne ({
'name':'office address'
'province':'jiangsu'
'city':'nanjing'
})
View address_office data
Db.address_office.find () .pretty ()
7. Create a user collection (users)
Db.createCollection ("users")
8. View create collection
Show collections
9. Add data to the users collection
Db.users.insertOne ({
"name": "suyanzhu"
"address": {
"$ref": "address_home"
"$id": ObjectId ("5bd2b70fabb45c7371f36eda")
}
"age": 18
})
View the data in the collection
Db.users.find () .pretty ()
10. View the specific address information of the user
Var user = db.users.findOne ({"name": "suyanzhu"})
User
Var dbRef = user.address
DbRef
Var collName = dbRef.$ref
CollName
Var id = dbRef.$id
Id
DB [collName] .findOne ({"_ id": id})
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.