Outils développeur

MongoDB Guide

Utilisez un utilitaire développeur ciblé pour données, code ou recherche.

CategoryCommandExplanation
ConnectionmongoshConnect to a local MongoDB server.
Connectionmongosh "mongodb://localhost:27017/app_db"Connect to a specific database with a connection string.
Databaseshow dbsList databases.
Databaseuse app_dbSwitch to a database. It is created when data is inserted.
Collectionshow collectionsList collections in the current database.
Collectiondb.createCollection("users")Create a collection explicitly.
Insertdb.users.insertOne({ email: "demo@example.com", createdAt: new Date() })Insert one document.
Insertdb.users.insertMany([{ email: "a@example.com" }, { email: "b@example.com" }])Insert multiple documents.
Readdb.users.find({ email: /@example.com$/ }).sort({ createdAt: -1 }).limit(20)Query, sort, and limit documents.
Readdb.users.findOne({ email: "demo@example.com" })Find a single matching document.
Updatedb.users.updateOne({ email: "demo@example.com" }, { $set: { active: true } })Update one matching document.
Updatedb.users.updateMany({ active: { $exists: false } }, { $set: { active: true } })Update many matching documents.
Deletedb.users.deleteOne({ email: "demo@example.com" })Delete one matching document.
Deletedb.users.deleteMany({ active: false })Delete many matching documents.
Indexdb.users.createIndex({ email: 1 }, { unique: true })Create a unique ascending index.
Indexdb.users.getIndexes()List collection indexes.
Aggregationdb.orders.aggregate([{ $group: { _id: "$userId", total: { $sum: "$total" } } }])Group documents and compute totals.
Countdb.users.countDocuments({ active: true })Count matching documents.
Backupmongodump --db app_db --out ./backupExport a database backup.
Restoremongorestore --db app_db ./backup/app_dbRestore a dumped database.

Concepts

MongoDB basics

ConceptMeaning
DocumentA JSON-like BSON object stored in a collection.
CollectionA group of documents, roughly comparable to a table but schema-flexible.
DatabaseA namespace containing collections and indexes.
ObjectIdThe common default value for the _id primary key.
IndexA data structure that speeds up reads and supports uniqueness constraints.
AggregationA pipeline for transforming, grouping, filtering, and joining document data.

FAQ

Questions fréquentes

À quoi sert MongoDB Guide ?

MongoDB Guide permet de réaliser ce flux directement dans le navigateur.

Faut-il un compte ?

Non. Les outils NovaKit sont conçus pour un usage direct sans compte.

Puis-je copier ou télécharger le résultat ?

Quand une sortie est générée, la page propose des actions de copie, téléchargement ou export.

Outils liés

Continuer le travail