Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
SolvedPrivate

MongoDB Record Delete using JavaScript

Posted on 2013-12-17
1
Medium Priority
?
74 Views
Last Modified: 2016-02-10
I am trying to delete a bunch of records from MongoDB, but am having some issues with my JavaScript. It seems to go through the first 10 records and stop. Here is what I have so far:

function getObjectIDs() {
          var IDs = db.mycollection.find({log:{$lt:ISODate('2013-06-01T00:23:24.154Z')}}, {_id:1});
          return IDs;
}

function removeID(db, userId) {

          db.mysecondcollection.remove({user:userId});

}

var IDs = getObjectIDs();

IDs.forEach(function(ID) {
          removeID(db, ID._ID);
});

Open in new window


Can anyone see what I may be doing wrong?
0
Comment
Question by:c0mrad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39726424
in the mongo console what do you get with the following :

db.mycollection.find({log:{$lt:ISODate('2013-06-01T00:23:24.154Z')}}, {_id:1}).length;

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question