This commit is contained in:
Matt Styles
2013-05-14 23:35:33 +01:00
parent fede7c4914
commit 48aa210dc3
2 changed files with 6 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
var appConfig = require( '../../app-config.json' ),
db = require( '../db' ).db( appConfig.database.name );
// Example route
// Example route - returns all items in database collection
module.exports = function( req, res ) {
console.log( 'Accessing database ' + db.databaseName );

View File

@@ -1,8 +1,10 @@
'use strict';
/* jshint camelcase: false */
// Dependencies
var mongo = require( 'mongodb' ),
appConfig = require( '../../app-config.json' );
appConfig = require( '../../app-config.json' ),
createDummyCollection;
// Create mongo server
var server = new mongo.Server( appConfig.database.host, appConfig.database.port, { auto_reconnect: true } ),
@@ -35,7 +37,7 @@ client.open( function( err, client ) {
return err;
}
if ( !items.length > 0 ) {
if ( items.length <= 0 ) {
createDummyCollection( collection );
}
} );
@@ -45,7 +47,7 @@ client.open( function( err, client ) {
// Create dummy data for the collection
var createDummyCollection = function( collection ) {
createDummyCollection = function( collection ) {
console.log( 'Creating collection...' );
var dummy = [{