Push items into mongo array via mongoose

Assuming, var friend = { firstName: ‘Harry’, lastName: ‘Potter’ }; There are two options you have: Update the model in-memory, and save (plain javascript array.push): or I always try and go for the first option when possible, because it’ll respect more of the benefits that mongoose gives you (hooks, validation, etc.). However, if you are doing … Read more

Python dictionary : removing u’ chars

Some databases such as Sqlite3 let you define converter and adapter functions so you can retrieve text as str rather than unicode. Unfortunately, MongoDB doesn’t provide this option for any of the commonly needed types such as str, decimal or datetime: http://api.mongodb.org/python/current/tutorial.html#a-note-on-unicode-strings http://api.mongodb.org/python/current/faq.html#how-can-i-store-decimal-decimal-instances http://api.mongodb.org/python/current/faq.html#how-can-i-save-a-datetime-date-instance Having eliminated Mongo options, that leaves writing Python code to do the conversion after the data is retrieved. … Read more

MongoDb shuts down with Code 100

MongoDB needs a folder to store the database. Create a C:\data\db\ directory: and then start MongoDB: Sometimes C:\data\db folder already exists due to previous installation. So if for this reason mongod.exe does not work, you may delete all the contents from C:\data\db folder and execute mongod.exeagain.

(node:63208) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

The issue is that mongoose still uses collection.ensureIndex and should be updated by them in the near future. To get rid of the message you can downgrade by using version 5.2.8 in your package.json (and delete any caches, last resort is to uninstall it the install it with npm install [email protected]): “mongoose”: “^5.2.8” EDIT: As of this edit, Mongoose … Read more

Mongod complains that there is no /data/db folder

You created the directory in the wrong place /data/db means that it’s directly under the ‘/’ root directory, whereas you created ‘data/db’ (without the leading /) probably just inside another directory, such as the ‘/root’ homedirectory. You need to create this directory as root Either you need to use sudo , e.g. sudo mkdir -p /data/db Or you … Read more