Permalink
Browse files

beginning of database abstraction;

  • Loading branch information...
1 parent 9ca6984 commit 831232a20b13b8209a5685fed6158b73b30c2435 @thecolorblue committed Apr 23, 2011
Showing with 56 additions and 2 deletions.
  1. +20 −0 murray/db.js
  2. +16 −0 murray/dbs/mongo-native.js
  3. +2 −1 murray/index.js
  4. +8 −0 murray/settings.js
  5. +10 −1 murray/theme/template.html
View
20 murray/db.js
@@ -0,0 +1,20 @@
+// We need this to look up what database you want to use
+var settings = require('./settings.js');
+
+// A couple extra variables
+var dbdriverfile = __dirname + '/dbs/' + settings.database + '.js';
+
+// require db 'driver'
+var dbDriver = require(dbdriverfile);
+
+// Setup Db object
+var Db = {};
+
+// set functions from 'driver' to functions for murray
+Db.get = dbDriver.get;
+Db.post = dbDriver.post;
+Db.put = dbDriver.put;
+Db.delete = dbDriver.delete;
+
+// export so murray can use them
+module.exports = Db;
View
16 murray/dbs/mongo-native.js
@@ -0,0 +1,16 @@
+var Db = require('mongodb').Db,
+ Connection = require('mongodb').Connection,
+ BSON = require('mongodb').BSONNative,
+ Server = require('mongodb').Server;
+
+Mongo = {};
+
+Mongo.get = function(){};
+
+Mongo.post = function(){};
+
+Mongo.put = function(){};
+
+Mongo.delete = function(){};
+
+module.exports = Mongo;
View
3 murray/index.js
@@ -1,4 +1,5 @@
-// Murray CMS Helpers
+var settings = require('./settings.js');
+console.log(settings);
var Db = require('mongodb').Db,
Connection = require('mongodb').Connection,
Server = require('mongodb').Server,
View
8 murray/settings.js
@@ -0,0 +1,8 @@
+Settings = {};
+
+// Settings go here
+Settings.database = 'mongo-native';
+
+
+// Do not touch under here
+module.exports = Settings;
View
11 murray/theme/template.html
@@ -1 +1,10 @@
-<!DOCTYPE html><html><head></head><body><: posts :><: sidbar :><: forms :></body></html>
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+ <body>
+ <: posts :>
+ <: sidbar :>
+ <: forms :>
+ </body>
+</html>

0 comments on commit 831232a

Please sign in to comment.