# 27017/TCP (MongoDB)

## Información general

```shell
# Bases de datos
show databases;

# Colecciones
use <database-name>;
db.getCollectionNames();

# Documentos
use <database-name>;
db.<collection-name>.find();
```

## Creación de base de datos

```shell
use <database-name>;
```

## Creación de colección

```shell
use <database-name>;
db.createCollection("<collection-name>")
```

## Ingreso de documento

```shell
use <database-name>;
db.<collection-name>.find();
db.<collection-name>.insert(<json>);
db.<collection-name>.find();
```

## Actualización de campo de documento

```shell
use <database-name>;
db.<collection-name>.find();
db.<collection-name>.update({id:1}, {$set: {field: "value"}});
db.<collection-name>.find();
```

## Eliminación de documento

```shell
# Listar documentos
use <database-name>;
db.<collection-name>.find();

# Eliminación de un documento
db.<collection-name>.remove({id:1});

# Eliminación de todos los documentos de una colección
db.<collection-name>.drop();
```


---

# 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://pentesting.mrw0l05zyn.cl/escaneo-y-enumeracion/servicios/27017-tcp-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.
