Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7566059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:18:58+00:00 2026-05-30T14:18:58+00:00

Which is the best way to store meta data for a document, in the

  • 0

Which is the best way to store meta data for a document, in the document itself or in separate collection?

I am working with a collection that has data like this:

{
   status: {
       joined: Date,
       retired: [{
           on: Date,
           comment: String,
           reinstated: {
               on: Date,
               comment: String
           }
       }],
       suspended: [{
           on: Date,
           comment: String,
           reinstated: {
               on: Date,
               comment: String
           }
       }],
       //.....

I need to keep a log of when and who performs these changes, but I am not sure if I should add the metadata to each element or have a collection like Log.

// Log collection
{
    by: UserId,
    on: Date,
    verb: String,
    object: ObjectId,
    comment: String
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:19:00+00:00Added an answer on May 30, 2026 at 2:19 pm

    I would store meta data with document for few reasons:

    1. It will look more natural if you keep the document and its metadata together.

    2. When you load document you can easily exclude metadata from the document to keep your documents light when metadata is not needed:

      db.items.find( { }, { metadata : 0 } );

    3. You can easily use paging to retrieve metadata using $slice:

      db.items.find({}, {metadata:{$slice: [20, 10]}}) // skip 20, at most 10

    But, also keep in mind that:

    1. The size limit of a document is 16MB. If you’re planning to have a lot of metadata, then better go with a separate collection. But I usually start from embedding the data, and later migrate it to a separate collection if it becomes too big.

    2 .If you need to show the metadata across all documents somewhere, like in a grid, it can be a pain to load it, apply paging, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which is Best way to send data to aspx page, and why ? using
my question is the following, which is the best way of working XML (kml)
Which is the best way to store a symmetric matrix in memory? It would
What is the best way to store and map an Entity which contains a
I am looking for the best way to store data in a game. Currently
Which is the best way to store application and user settings of an application
What is the best way to store data for the iPhone? I will be
Just wondering what the best way to store user login data on successful login
Which is the best way to store images in an array? I'm using ImageIO
What's the best way to store, index, and lookup text strings (URLs in this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.