Skip to content
Browse files

initial check-in

  • Loading branch information...
0 parents commit 8a4fb06cd46bda38dca4b38ff008797f334c9e38 @donpark committed Jul 5, 2011
Showing with 71 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +31 −0 README.md
  3. +6 −0 index.coffee
  4. +15 −0 index.js
  5. +18 −0 package.json
1 .gitignore
@@ -0,0 +1 @@
+node_modules
31 README.md
@@ -0,0 +1,31 @@
+I wrote Mongeese because I couldn't figure out how to transparently access
+multiple MongoDB databases using [Mongoose](http://mongoosejs.com) API.
+
+## Install
+
+ npm install mongeese
+
+## Usage
+
+Replace code requiring `mongoose` module like this:
+
+ var mongoose = require("mongoose");
+ mongoose.connect(...);
+
+with:
+
+ var mongoose = require("mongeese").create();
+ mongoose.connect(...);
+
+Result of `create` method call should look and behave exactly like `mongoose` module
+except each result can have its own *default connection*.
+
+If you need to handle multiple databases at the same time, following should suffice:
+
+ var logdb = require("mongeese").create();
+ var keydb = require("mongeese").create();
+
+ logdb.connect('mongodb://localhost/log');
+ keydb.connect('mongodb://localhost/key');
+
+That's it.
6 index.coffee
@@ -0,0 +1,6 @@
+mongoose = require('mongoose')
+
+exports.create = ->
+ mongeese = new mongoose.Mongoose()
+ mongeese[key] = value for key, value of mongoose when not mongeese[key]? and mongoose.hasOwnProperty(key)
+ mongeese
15 index.js
@@ -0,0 +1,15 @@
+(function() {
+ var mongoose;
+ mongoose = require('mongoose');
+ exports.create = function() {
+ var key, mongeese, value;
+ mongeese = new mongoose.Mongoose();
+ for (key in mongoose) {
+ value = mongoose[key];
+ if (!(mongeese[key] != null) && mongoose.hasOwnProperty(key)) {
+ mongeese[key] = value;
+ }
+ }
+ return mongeese;
+ };
+}).call(this);
18 package.json
@@ -0,0 +1,18 @@
+{
+ "author": "Don Park <donpark@docuverse.com> (http://blog.docuverse.com)",
+ "name": "mongeese",
+ "description": "Mongoose multi-database helper",
+ "version": "0.0.1",
+ "main": "./index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/donpark/mongeese.git"
+ },
+ "engines": {
+ "node": ">= v0.4.0"
+ },
+ "dependencies": {
+ "mongoose": ">= 1.1.0"
+ },
+ "devDependencies": {}
+}

0 comments on commit 8a4fb06

Please sign in to comment.
Something went wrong with that request. Please try again.