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 1022695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:30:15+00:00 2026-05-16T11:30:15+00:00

I have a special list (a sort of queue, as in the data structure,

  • 0

I have a special list (a sort of queue, as in the data structure, not as in a work queue) that I want to store in MongoDB. I need to access and manipulate this single list often in my application – and I don’t have several of the same type of list.

It would be easiest to store it in a single document, but the problem I’m having is figuring out the best way to reference that particular document from my application code. I don’t want to have to query several documents to locate the correct one, since only one document will contain this list.

I’d also rather not split the list into several documents in a collection, since it is just a short, simple list (it is limited to 400 elements, and each element is just a short piece of text, so there is no risk of overrunning the 4MB document limit).

I’ve thought of several ways I could do this, but none seem ideal. Please let me know if one is the right approach, or if I’m missing something.

  1. Set a custom _id for the document, and hard-code it in my application.
  2. Create a collection for the document which will contain only that one document, so that I can retrieve it by just getting the first document in that collection. (This seems hacky)
  3. Use a field like document_name: 'my_special_list' and retrieve the document by querying on document_name. I’d rather not do this since I have no need for other documents like this, so only one document would have that document_name field.
  4. Use a collection of documents, each containing an index field and an element content field, and use map-reduce to get a list from it, or something along those lines. I’d rather not do this since simply retrieving a BSON list, manipulating it and storing it back in the document is so much more straightforward.
  5. Use a different technology for this, since MongoDB isn’t suited for it.
  • 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-16T11:30:15+00:00Added an answer on May 16, 2026 at 11:30 am

    The MongoDB documentation states:

    Users are welcome to use their own conventions for creating ids; the _id value may be of any type so long as it is a unique.

    So option 1 would be the way I’d do it.

    Update

    Option 2 is somewhat of a hack, as you said yourself.
    Option 3 introduces an additional field for something you can use the _id field for just as well.
    Option 4 is a complex solution to a simple problem.

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

Sidebar

Related Questions

I have a list that I want to be able to store 20 values.
I have defined a custom Sharepoint list for special attributes related to a software
I have a special url which I would want only few people to have
I have an application that has to deal with getting special characters in its
For some reason the Windows command prompt is special in that you have to
I have a special situation where I need to query a service to get
I have a list of tags that I would like to add to a
I have written a class that will be used to store parameters in a
Applications which run on mobile devices have special user interface requirements. I think Apple
Does * have a special meaning in Python as it does in C? I

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.