Eğitim için hazırlnamış bir konteyner
1.2K
MongoDB; MongoDB Inc. tarafından ölçeklenebilir, doküman tabanlı, C++ ile geliştirilmiş açık kaynak, NoSQL veritabanı uygulamasıdır.
| RDBMS | MongoDB |
|---|---|
| Database | Database |
| Table | Collection |
| Tuple/Row | Document |
| column | Field |
| Table Join | Embedded Documents |
| Primary Key | Primary Key (Default key _id provided by MongoDB itself) |
Mongodb Kurulumu
docker pull erelbi/mongodb-test
Container ayağa kaldırılması
docker run --name mongodb-test -dp 27017:27017 erelbi/mongodb-test
docker exec -it mongodb-test /bin/bash
Örnek Veritabanının Yüklenmesi
bash /tmp/testdb_create.sh
>>connected to: mongodb://localhost/
>>25359 document(s) imported successfully. 0 document(s) failed to import.
Mongo Kabuğuna Bağlantı
mongo
Beklenen Çıktı:
MongoDB server version: 4.4.5
---
The server generated these startup warnings when booting:
2021-04-24T14:56:28.563+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-04-24T14:56:29.286+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2021-04-24T14:56:29.286+00:00: You are running this process as the root user, which is not recommended
2021-04-24T14:56:29.286+00:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
---
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
>
show dbs;
Beklenen Çıktı:
admin 0.000GB
config 0.000GB
local 0.000GB
testdb 0.009GB
use testdb
db.test.insert({"name":"test","surname":"eğitim"})
db.getCollectionNames()
db.test.updateOne({"name":"test"},{$set:{"surname":"öğretim"}} )
Beklenen Çıktı:
WriteResult({ "nInserted" : 1 })
Test:
db.test.findOne({})
{
"_id" : ObjectId("6084364599678331093b0684"),
"name" : "test",
"surname" : "öğretim"
}
db.test.update({},{$set: {"new_field*":1}},false,true)
Beklenen Çıktı:
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Test:
db.test.findOne({})
{
"_id" : ObjectId("6084364599678331093b0684"),
"name" : "test",
"surname" : "öğretim",
"new_field*" : 1
}
db.test.update( { _id: ObjectId("6084364599678331093b0684") },{ $unset: {"new_field*": ""}})
!!! id değerine bakınız. İd değerinin eşleşmesi gerekmektedir.
Beklenen Çıktı:
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Test:
db.test.findOne({})
{
"_id" : ObjectId("6084364599678331093b0684"),
"name" : "test",
"surname" : "öğretim"
}
use veritabanı
db.dropDatabase()
Content type
Image
Digest
Size
434.5 MB
Last updated
over 5 years ago
docker pull erelbi/mongodb-test