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

  • Home
  • SEARCH
  • 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 8263673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:11:17+00:00 2026-06-08T04:11:17+00:00

I am accessing MongoDB documents with a node.js web-front-end while in developement. I got

  • 0

I am accessing MongoDB documents with a node.js web-front-end while in developement.

I got now following document:

{
   "_id": ObjectID("500abe6a25dff13c7c000001")
    , "username": "kyogron"
    , "email": "kyogron@example.de"
    , "contacts": [ObjectID("500abe6a2543213c7c000002")] // this should contain other user's id
}

I now want to add another user_id to the contacts array manually, before implementing the feature in the front-end.

As you see above I alread tried this using the ObjectID keyword but this didn’t work…

  • 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-08T04:11:19+00:00Added an answer on June 8, 2026 at 4:11 am

    This worked for me from the MongoDB shell, I’m using $addToSet instead of $push because I assume you want to avoid dupes:

    var o = new ObjectId();
    db.foo.update({}, {$addToSet : {"contacts" : o}});
    var o = new ObjectId();
    db.foo.update({}, {$addToSet : {"contacts" : o}});
    

    That gave me a document that looks like this (my foo collection only contained your sample, so I didn’t have to have a specific matching criteria):

    {
        "_id" : ObjectId("500c2118c78bb07bfbb69eb3"),
        "contacts" : [
            ObjectId("500c20efc78bb07bfbb69eb2"),
            ObjectId("500c227ac78bb07bfbb69eb6")
        ],
        "email" : "kyogron@example.de",
        "username" : "kyogron"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Mongoose Library for accessing MongoDB with node.js Is there a way
I accessing a web service after i parsing that that code i got AiringTime
While accessing our own website in Java code, an exception is thrown: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException:
Accessing following html directly from file system gives me the correct duration. <video src=multimedia/bbb400p.ogv
When accessing my site, the SSL session is successful while the page loads. A
While accessing information using Capabilities, i am getting incorrect values. var screenX:Number = Capabilities.screenResolutionX;
I've been accessing Plesk Admin for a while at http://yourarthere.net:8443 but since I moved
I recently asked about accessing data from SPSS and got some absolutely wonderful help
Accessing an array element with the following line works great; if (dataset[i].properties.property == value)
Accessing Web Services inside an iPhone app is a matter for which I did

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.