MongoDB Atlas ofrece una forma sencilla de alojar y gestionar tus datos en la nube.
On this page
Introducciónn
Entorno de trabajo
Instal.la el Atlas CLI:
> scoop install main/mongodb-atlas-cliRegístrate para obtener una cuenta de Atlas mediante tu cuenta de Google o una dirección de correo electrónico:
> atlas auth registerAl registrarte has iniciado sesión, pero en cualquier momento puedes volver a iniciar sesión con:
> atlas auth loginAtlas crea una organización por defecto:
> atlas organizations listID NAME67877b1e25674900296a4ece David's Org - 2025-01-15Configura por defecto la organización que se ha creado:
> atlas config set org_id 67877b1e25674900296a4eceUpdated property 'org_id'Base de datos
A continuación crea el proyecto acme:
> atlas projects create acmeProject '67879c731bae49103f7c97c5' created.Configura por defecto el nuevo proyecto:
> atlas config set project_id 67879c731bae49103f7c97c5Updated property 'project_id'A continuación despliega un cluster gratuito (sólo puedes tener uno por proyecto):
> atlas setup --clusterName acme --provider AWS --region EU_WEST_3 --username acme --password P@ssw0rd --skipSampleData --forceWe are deploying orders...
Store your database authentication access details in a secure location:Database User Username: shopDatabase User Password: P@ssw0rd
Creating your cluster... [It's safe to 'Ctrl + C']Cluster created.Your connection string: mongodb+srv://acme.trjoh.mongodb.netconnection skippedYa puedes conectarte al cluster:
> mongosh "mongodb+srv://acme.trjoh.mongodb.net/shop" --apiVersion 1 --username acmePuedes ver sus datos, importar documentos y ejecutar consultas.
Atlas App Services (Web SDK)
This is the “official” way to connect a frontend to MongoDB.
It handles authentication and security rules so users can’t just delete your entire database.
How it works:
- Enable App Services: In your Atlas dashboard, click the App Services tab and create a new App.
Set up Authentication: Enable “Anonymous” or “Email/Password” login.
Define Rules: Set permissions (e.g., “Users can only read their own documents”).
Install the Library:
deno install realm-web