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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:40:09+00:00 2026-06-05T11:40:09+00:00

Mongo make an array with date as key ? [_id] => MongoId Object (

  • 0

Mongo make an array with date as key ?

[_id] => MongoId Object (
    [$id] => 4fcf2f2313cfcd225700000d
)
[id] => 14
[name] => Aryan Roban
[news] => Array (
    [08-06-2012] => 12
)

Here I want a make news as array with date as key and how to delete a particular key row ?

For example

I want to delete array element with key ’08-06-2012′ in news array , I dont know the value of 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-06-05T11:40:10+00:00Added an answer on June 5, 2026 at 11:40 am

    Finding Documents won’t be a problem, this is very easy. Simply look if news has got a key which matches your search criteria:

    db.foo.find({'news.08-06-2012': {'$exists': true}})
    

    Don’t forget to put an index on news.

    But deleting them is not easily possible. There is another thread which show shows a way to do that, but it’s really rather a workaround: In mongoDb, how do you remove an array element by its index Sadly this only works for arrays with numerical indexes and not for associative arrays.

    Maybe you could use an own collection for news? Then you could update and delete them easily. Otherwise you could load a full document from your database, manipulate the news in your application and save it afterwards. This would require two datebase queries, but should work.

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

Sidebar

Related Questions

I have documents in Mongo that contain questionnaire-like data (company's name, address, phone numbers,
Consider the following example of mongo collection: {_id : ObjectId(4f304818884672067f000001), hash : {call_id :
I have an object that was stored via mongo-java-driver. Object uses java.util.UUID for its
I want to ask it is better to make a query in mongo db
I'm toying with Mongo to make a SO-like pet project, and I want to
I am using Mongo Mapper and I'm trying to figure out how you make
I would very much like to use the mongo geoNear command as discussed here
I'm a Mongo newbie, and trying to make this schema work. Its intended for
Mongo DB: I'm looking to make one query to return both the first and
Im trying to make this query on Mongo: {localization: {$within : {$box : [

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.