Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 1.28 KB

mongodb-indexes.md

File metadata and controls

28 lines (18 loc) · 1.28 KB

🌐 CIRCUIT ON

📇 MongoDB Structure

Considerations about MongoBD usage on this project:

  • In order for the image files to be saved in a MongoDB database, they are converted into base-64 data and saved in the "images.data" field.
  • An embed field named "image" under "schedules" allows quick access to most-used image properties, without the needing to perform the database lookup for quering those fields. Only when required, the $lookup (aggregation) is used for joining schedules and images information.

This project would create the following collections on the MongoDB Database:

  1. Images collection: Images Documents
  2. Schedules collection: Schedules Documents

🗂 MongoDB Indexes

After creating the first documents on the collections, additional Indexes can support faster queries.

  • Add the following index to support the aggregation pipeline getGroupedByCategory at src/api-modules/images/images.service.ts:
    db.images.createIndex({ category: 1, updatedAt: -1 });

📝 Docs and external resources: