# MongoDB

#### คำสั่ง SQL VS MONGO

| SQL      | MongoDB  |
| -------- | -------- |
| WHERE    | $match   |
| GROUP BY | $group   |
| SELECT   | $project |
| ORDER BY | $sort    |
| LIMIT    | $limit   |
| JOIN     | $lookup  |

#### การสร้างและลบฐานข้อมูล

* การแสดงฐานข้อมูล

cmd

```
show dbs
```

* การสร้าง หรือ เลือกฐานข้อมูล

cmd

```
use dbName
```

(หากมี db อยู่แล้วจะเป็นการเรียกใช้ แต่ถ้าหากไม่มี จะเป็นการสร้างขึ้นมาแทน)

* การลบฐานข้อมูล

cmd

```
db.dropDatabase()
```

(ต้องอยู่ในฐานข้อมูลนั้นก่อนเช่น `use staff` ตามด้วย `db.dropDatabase`)

#### การจัดการ Collection

* การสร้าง Collection

cmd

```
db.createCollection("CollectionName")
```

* การแก้ไขชื่อ Collection

cmd

```
db.collectionName.renameCollection("newCollectionName")
```

* การลบ Collection

cmd

```
db.collectionName.drop()
```

#### ชนิดข้อมูลใน Mongodb

| ชนิดข้อมูล | รายละเอียด |
| :--------: | ---------- |
|   String   |            |
|            |            |
|            |            |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.0xmrjane.com/mongodb.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
