How MongoDB store the documents?

Hi I want to know how MongoDB save documents, for example, this create a single one file for each document?

No it does not. See https://docs.mongodb.com/manual/core/wiredtiger/ for more information.

Welcome to the MongoDB Community Forums @Jean_N_A !

In addition to the general storage engine reference that @steevej provided, you may find some of the following details helpful:

  • The server-side representation of a document uses BSON data types. BSON is binary JSON-like serialisation format that adds additional data types such as numeric (32-bit integer, 64-bit integer, 128-bit Decimal), Date, and ObjectId.

  • MongoDB drivers handle server communication and serialisation, so you usually end up working with native objects in your chosen development language rather than directly writing BSON.

  • Documents are stored on disk using block compression to reduce storage usage. Documents are automatically uncompressed in memory when retrieved by the MongoDB server.

  • Each collection & index is stored in a separate file within the storage.dbPath for your deployment. The dbPath also includes other essential metadata files for your deployment, so a valid backup requires the full contents of your dbPath or a copy of your data via a supported MongoDB Backup Method.

Regards,
Stennie