Articles & Videos



MongoDB (from humongous) is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas. MongoDB is developed by MongoDB Inc. and is free and open-source, published under a combination of the GNU Affero General Public License and the Apache License.

Share tech news, updates, or what's on your mind.

Sign up to Post

I am trying to connect to MongoDB in mongoDBatlas from my javascript but I keep getting the following error.

MongoError: connection 5 to closed
    at Function.MongoError.create (C:\Users\558642\ga\js-dc-5\11-crud-and-dbs\assignment\todo\node_modules\mongodb-core\lib\error.js:29:11)
    at TLSSocket.<anonymous> (C:\Users\558642\ga\js-dc-5\11-crud-and-dbs\assignment\todo\node_modules\mongodb-core\lib\connection\connection.js:202:22)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:101:20)
    at TLSSocket.emit (events.js:191:7)
    at _handle.close (net.js:511:12)
    at Socket.done (_tls_wrap.js:332:7)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at TCP._handle.close [as _onclose] (net.js:511:12)

Here's my code
const express = require('express')
const hbs = require('express-handlebars')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')


const itemEntry = require('./models/toDoEntry.js')
const app = express()

app.get('/', function( req, res ) {
	itemEntry.find({}, function( err, itemEntries ) {

Open in new window

Webinar: Security & Encryption in the MySQL world
Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

I am using php and mongoDb. I am new to mongoDb, but fine with php.  In my mongoDb database I have a  collection called 'users' with a number of fields such as firstname, lastname etc. There are a number of users.

I also have a field/collection in some users called web_links which contains an array.
ie: within my users document:
    "_id" : ObjectId("587af11ec09cf31a1955ed92"),
    "username" : "mike",
    "firstname" : "Mike",
    "lastname" : "Tester",
    "email" : "",
    "web_links" : [
            "name" : "google",
            "link" : "",
            "status" : "1",
            "added" : ISODate("1970-01-18T08:00:57.600Z")
            "name" : "yahoo",
            "link" : "",
            "status" : "1",
            "added" : ISODate("1970-01-18T08:00:57.600Z")

I am trying to firstly update the status of an array item.
I have got as far as this ->

$name = 'google';
$newstatus = '0';

$this->database->users->updateOne(['_id'=>new MongoDB\BSON\ObjectId($userid)],[''=>$name],['$set'=>['web_links.$.status'=>$newstatus]]);

This is returning the following error via firebug:
Uncaught exception 'MongoDB\Exception\InvalidArgumentException' with message 'First
 key in $update argument is not an update operator'.

I have tried to change $set to $push, but that is not the answer.

I would be very grateful for assistance …
I am learning Angular, Node, npm, deployd, mongodb, etc.  I am making my way through a book titled "Pro AngularJS" by Adam Freeman.

on page 120 I am attempting to prepare the data for a "real world" application called "sportsstore".

I was instructed to install a module called "deployd" which apparently is used for modelling  API's for web applications.

I did that and when I try to start start the "deployd" service I get an error:

C:\PROGRA~2\deployd>dpd -p 5500 sportsstore\app.dpd --mongod
starting deployd v0.8.9...
  var err = this._handle.spawn(options);

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:289:26)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.restart (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\lib\util\mongod.js:38:14)
    at Command.start (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\bin\dpd:149:16)
    at Command.listener (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:301:8)
    at emitOne (events.js:96:13)
    at Command.emit (events.js:188:7)
    at Command.parseArgs (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:617:12)
    at Command.parse (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:458:21)
    at Object.<anonymous> 

Open in new window

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
A simple login application using Node JS, Mongo DB and Express frameworks. There are tons of tutorials on Node JS and Express but most of the use extensive plugins which would confuse the beginners, the primary motive of this article is to ensure it captures the bare minimal functionality.
Hi there,

I have a mongo aggregation query that works fine in the mongo shell (and robomongo) but I can not work out how to translate this into a PHP query.

I am using PHP 5.6 with the latest mongo class (MongoDB\Driver\Query).  The mongo query looks like this:

     {$match: {
             vendor_name : "vendor8",
             distributor_id : 8
     { $sort: { 
         cw_product_code: 1, download_Date: 1 
     { $group:
           _id: "$cw_product_id",
           lastDownloadDate: { $last: "$download_Date" },
     {allowDiskUse: true}     

Open in new window

Any help to point me in the right direction would be appreciated.
hi, i have the following document on mongodb

name: "john",
state: "GA",
city: [
     {"atlanta", 30350},
     {"atlanta", 30351},
     {"atlanta", 30352},
     {"marietta", 45093}

how do i aggregate the array of citys and get a document like this:

name: "john",
state: "GA",
city: [
     {"atlanta", "30350, 30351, 30352"},
     {"marietta", "45093"}
Upcoming Webinar: Securing your MySQL/MariaDB data
Upcoming Webinar: Securing your MySQL/MariaDB data

Join Percona’s Chief Evangelist, Colin Charles as he presents Securing your MySQL®/MariaDB® data on Tuesday, July 11, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

What is the equivalent package for oracle  dbms_application_info..set_module in postgreSQL
Hi Experts,

I have a database that did grow monthly the following in MB
What is the way to calculate the expected growth for the next few months?
I have 2 tables that look like this:

Table1: EntityID, FamilyID

Table 2: EntityID, ParentEntityID

Table 1 contains a list of entities with FamilyID column currently all NULLs. Table 2 provides family information between entities. E.g.: an entity can be linked to a parent entity, a grandparent entity, to grandparent, etc.. A single entity can be linked to multiple parent entities too (just like in Family2 in the example below)

I am looking for an SQL that generates and populates a unique family ID for all linked Entities in the Table1. Example, if Table2 has the following data:

Than Table1 FamilyID column should be populated as follows:
1, family1
2, family1
3, family2
4, family2
5, family2
6, family2

Note, Table2 currently has 3 million records. And table 1 has about 5.5 million not all entities have parents)...

Thank you, Experts!
Hi Experts,

We have SQL Express 2005 and I realized our data file is almost reaching the limit (4GB).
Now my question is, how can I shrink the size of the file in order to prolong the need to upgrade (FE/BE)?

Also I see one table that has about 200 MB used for data and 450 MB for indexes, is that acceptable?
How can I see what indexes are not being used so frequent and can be dropped (for a particular table or in general)?

PS. Our front end app is an Access ADP and then therefore I don't see how the database can be split.

Thanks in advance.
I have a SP in which i need to add one condition to check multiple databases by using sys.dm_database_encryption_keys table. 

when encryption_state is 2 and percentage_completed is 0 in the results it should print. Below is my query

DECLARE @Test varchar(10)
SELECT @Test = Database_ID from 
WHERE Encryption_state = 2 and complete_percentage = 0
If (@test not NULL)

If i have multiple DB's which meets the about. It should PRINT multiple ALTER statements with DB Names
Hi I have a colleague who has a SQL Script that she runs in Crystal Reports.  I need this similar script to run on our AIX box for a certain program.  It runs fine in Crystal, but it just hangs on our IBX AIX box.

It has like 14 SELECT Statements.  Is there a way I can step through this script in SQL, like a debug tool, so I can see why it is running a long time or failing without me knowing?  I wish there was a log file or something?  Is there??

Thanks in advance for help!
Lets say you have a table:
Name   City            Date
Bob      Anytown   2017-03-15
Bob      Anytown   2017-03-21
Jim       Sometown 2017-02-27
John    Mytown      2017-03-06
John    Mytown      2017-03-19
John    Mytown      2017-03-25

I need to query the table so that my results are as follows:
Name  City            Dates
Bob     Anytown    2017-03-15,2017-03-21
Jim      Sometown 2017-02-27
John    MyTown     2017-03-06,2017-03-19,2017-03-25

I guess I'm asking how can I (can I?) have the results of a single field query reported in a single row rather than multiple rows?


I know how I can use a programming language to manipulate this (VB/ASP for example), with looks, but I'm looking for a pure SQL way.  IDEALLY MySQL way.
we have located a sql script (*.sql) on a file share which seems to show passwords for an initial creation of a SQL database, for example it has sp_addlogin commands, and then a number of accounts and passwords.

However, the password does not seem to comprise of standard alpha numeric characters, and contains a number of "special" characters, e.g. µ, ·, â, Ë

can SQL Server handle these characters in a password, or is it more likely this is some sort of encrypted representation of the password? Or can you use any character you like in a SQL Server password? It seems a bizarre combination if you ever had to enter those when entering a password to access a database, I was just intrigued what it may be, and whether SQL Server can use those characters or if its restricted to more common values, e.g. a..z, A..Z, !"£$%^&*()-, 0..9 etc.
My data:

Gage_number Latitude    Longitude   Date    Gage_1  Gage_2  Gage_3

1   35.02   -80.84  1/1/2002    0.23    0   0.7
2   35.03   -81.04  1/2/2002    0   0   0.2
3   35.06   -80.81  1/3/2002    3.2 2.1 0.1
This is just a subset of data. I around 50 gauge stations. I want to find spatial auto correction between my gauge stations for rain fall. Based on distance between them. I have created my distance matrix. But I don’t want to use any library in R. I want to do all steps in a function.

loc <- read.table("rain_data.txt",header=TRUE,fill=TRUE)  
gauge.dists <- as.matrix(dist(cbind(loc$Latitude, loc$Latitude))) #distance matrix
Now since distance between gauges is not uniform. I want to use a certain bin size to decide about distance lags.


If the distance between guage pair 1-2 is 1 meter then assign a distance lag of 1 and so on So Lag 1=intergage dist=1 meter. So Lag 5=intergage dist=5 meter After creating that matrix I will find autocorrelation between gauge pairs.

so for lag 1 intergage dist=1 for lag 5 intergage dist=5

Gage pair   date    RainA   RainB       Gage pair   date    RainA   RainB

1-2 1/1/2002    0.23    0       1-3 1/1/2002    0.23    0.7
1-2 1/2/2002    0   0       1-3 1/2/2002    0   0.2
1-2 1/3/2002    3.2 2.1     1-3 1/3/2002    3.2 0.1
I have a hard time translating it into loop or a function. Any ideas?
Webinar: Choosing a MySQL HA Solution
Webinar: Choosing a MySQL HA Solution

Join Percona’s Principal Technical Services Engineer, Marcos Albe as he presents Choosing a MySQL High Availability Solution on Thursday, June 29, 2017 at 10:00 am PDT / 2:00 pm EDT (UTC-7).

Using Database 11g Release 2

When I run the following pl/sql script :

  FOR comp IN (SELECT val FROM productTable@remote_link2 WHERE PRODUCT_ID = 1111)

I get the error :
ORA-06550: line 2, column 34:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 2, column 16:
PL/SQL: SQL Statement ignored
ORA-06550: line 4, column 26:
PLS-00364: loop index variable 'COMP' use is invalid
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.

But when I run as pl/sql only the select statement in the for loop :
SELECT val FROM productTable@remote_link2 WHERE PRODUCT_ID = 1111;
I get the results.

Is the database link not compiling properly in a for loop?
Dear experts,

I have a query that look like this:

SELECT GUIDCustomer, MAX(CreatedDate) AS 'latestTransDate'
FROM Invoice i
WHERE Completed = 1
AND Type = 'O'

The result will give me the latest date of each customer in Invoice table when invoices are completed.

I also wish to obtain the GUIDInvoice from the above query but unfortunately, I need to add GUIDInvoice in GROUP BY clause.
What I want to achieve is to find the latest transaction date by each customer and also obtain the GUIDInvoice of the invoice with latest transaction date. I wish to know how can I adjust my query to obtain that result. Thanks
Our sql server is a VM with vmware.  I know that the classical way to set up partitions for a sql server was to have 3 partitions.
1) for the os
2) for the mdf
3) for the ldf files

I have also heard that since vmware has came to prominence that this is not a big concern anymore.  meaning....  you can responsibly run a sql server install on 2 partitions now.
1) os
2) mdf and ldf

Can someone confirm that it is ok to run sql servers with either setup.  currently we are choosing the second way of setting up our sql servers, but i have a vendor that is highly recommending that we go to the classic 3 partition setup.

Thanks a bunch!
I am working on the vehicle details normalization but I am not sure it is correct or not. could you check it for me please? -we have: vehicle make, manufacturer, model, colour, type, fuel, year and safety.
I have no idea about year and safety . Thanks for your help.

manufactures(manufactur_id, manufactur_name, manufactur_address, manufactur_website)

vehicle_model(model_id, model_name, manufactur_id(fk))





vehicle(vehicle_id, colour_id(fk), model_id(fk), fuel_id(fk), type_id(fk), ......)
I have an AMS / eCommerce application that runs on IIS7 / WIN2008 R2 SP1. Databases for this application sit on two nodes of SQL Server 2008 that runs on Windows Failover Cluster. In the light of needing to fix "Sweet32" vulnerability, which is removing 3DES cipher and removing TLS1.0 protocols I had to update SQL Server 2008 environment to SP4 and apply TLS1.2 patch to it. I also updated .NET 4.5.2 with a security patch from Microsoft.

So, once I did this, I disabled DES/3DES ciphers and TLS 1.0 protocols on the web server and my application stopped working. I get
"site currently unavailable" message on the web browser.

When I look at the event viewer on the web server, I get series of error messages.

Event ID: 1309
Event Code: 3005
Process name: w3wp.exe

Exception Information:
Exception type: SqlException
Exception message: A communication was successfully established with the server, but then an error occured during the login process. (Provider: SSL Provider, error:0 - The client and server cannot communicate, because they do not possess a common algorithm)

Then there are a number of Schannel events:

Event ID 36871: A Fatal error occured while creating an SSL client credential. The internal error state is 10013.

Any thoughts appreciated.
Thank you,
What kind of factors do you need to consider in terms of defining offline backup retention (tape) for your major IT systems/data. Do you work towards any specific retention policy, e.g. 6 months oldest, or if you are keeping things for over 6 months - for what purposes? Our main systems are all driven by MSSQL databases, and some apps enforce retention policies for the online copy of the data - just wondered what kinds of things you factor in to determine how long you retain offline backups for (tape) as offsite storage for D/R is not all that cheap.





Articles & Videos



MongoDB (from humongous) is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas. MongoDB is developed by MongoDB Inc. and is free and open-source, published under a combination of the GNU Affero General Public License and the Apache License.

Top Experts In