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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:00:31+00:00 2026-05-23T18:00:31+00:00

I found the following script: Device.find(function(err, devices) { devices.forEach(function(device) { device.cid = ”; device.save();

  • 0

I found the following script:

Device.find(function(err, devices) {
  devices.forEach(function(device) {
    device.cid = '';
    device.save();
  });
});

MongoDB has the "multi" flag for an update over multiple documents but I wasn’t able to get this working with mongoose. Is this not yet supported or am I doing something wrong?

Device.update({}, {cid: ''}, false, true, function (err) {
  //...
});
  • 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-23T18:00:31+00:00Added an answer on May 23, 2026 at 6:00 pm

    Currently I believe that update() in Mongoose has some problems, see:
    https://groups.google.com/forum/#%21topic/mongoose-orm/G8i9S7E8Erg
    and https://groups.google.com/d/topic/mongoose-orm/K5pSHT4hJ_A/discussion.

    However, check the docs for update: http://mongoosejs.com/docs/api.html (its under Model). The definition is:

    Earlier Solution(Depreciated after mongoose 5+ version)

    Model.update = function (query, doc, options, callback) { ... }
    

    You need to pass the options inside an object, so your code would be:

    Model.update = function ({}, {cid: ''}, {multi: true}, function(err) { ... });
    

    New Solution

    Model.updateMany = function (query, doc, callback) { ... }
    
    Model.updateMany = function ({}, {cid: ''}, function(err) { ... });
    

    I believe that Mongoose wraps your cid in a $set, so this is not the same as running that same update in the mongo shell. If you ran that in the shell then all documents would be replaced by one with a single cid: ''.

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

Sidebar

Related Questions

I found a script which has the following snippet:- userid=`expr \`id\` : .*uid=[0-9]*(\(.[0-9a-z]*\)) .*`
I have found the following script for dynamically assigning hotkeys to already open windows:
I found following in javascript code function calculateURI(uri) { return (namespace.push.configuration.uriPrefix || '') +
I just found the following code in a PHP script and was wondering why
I have found the following script which is apparently written using the javascript framework
I found the following awesome script to create a random color with javascript. var
I found following piece of code written as a shell script to read from
I have found the following script causes a segmentation fault and core in KornShell
I found the following bash script in order to monitor cp progress. #!/bin/sh cp_p()
Reading through documentation, I found following: 1.9.1 1.8.4 1.8.2 A version of 1.8.2 select

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.