Category Archives: MongoDB

Basic

robomongo.orgĀ – shows database Database Names cannot contain any characters /\. “$*<>:|? and null character, cannot be empty and must have less than 64 characters Field Names cannot contain dots and null characters Replica Sets can have up to 50 members; … Continue reading

Posted in MongoDB | Leave a comment

Save Data

test/fileName.js const assert = require(‘assert’); const DatabaseName = require(‘../models/databaseName’); //describe test describe(‘demo test’, function(){ //create test it(‘function description’, function(done){ var char = new DatabaseName({ name: ‘…’ }); char.save().then(function(){ assert(char.isNew === false); done(); }); }); }); package.json “scripts”: { “test”: “mocha” … Continue reading

Posted in MongoDB | Leave a comment

Mocha

Installation npm install mocha –save test/demo_test.js const assert = require(‘assert’); //describe test describe(‘demo test’, function(){ //create test it(‘function description’, function(){ assert(…); }); }); package.json “scripts”: { “test”: “mocha” } cmd npm run test

Posted in MongoDB | Leave a comment

Setup

Installation npm install npm install mongoose –save Command Prompt “C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe” Connecting to MongoDB test/connection.js const mongoose = require(‘mongoose’); //ES6 Promises mongoose.Promise = global.Promise; //Connect to database before tests run before(function(){ //Connect to Mongodb mongoose.connect(‘mongodb://localhost/’); mongoose.connection.once(‘open’, function(){ …; done(); }).on(‘error’, … Continue reading

Posted in MongoDB | Leave a comment