{"_id":"mal","_rev":"45-ab6c622acd4fd179bab2b4c02a55495e","name":"mal","description":"MAL MongoDB Access Layer. A MongoDB wrapper using the native-node-driver","dist-tags":{"latest":"0.4.0"},"versions":{"0.2.0":{"name":"mal","version":"0.2.0","description":"MAL: MongoDB Access Layer. A simple convienence data access layer for MongoDB using the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB","convenience methods for mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"@daithi44","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.1.11"},"engines":{"node":">= 0.8.10"},"readme":"MAL (Simple MongoDB Access Layer) v0.2\n======================================\n\n\nConvenience methods for access a connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\nTo create and instance of MAL\n\n1. Create a dbSettings object\n--------------------------------\n\t//example dbSettings Object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n\n2. var dbManager = new MAL(dbsettings, optionalCallback);\n----------------------------------------------------------------\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n\n\tvar dbManager = new MAL(dbsettings);\n\n\tCallback required\n\t------------------\n\n\t//example\n\n\tfunction optionalCallback(db){\n\t  var callback = function(err, collection){\n\t\tcollection.find({status:1}, {id:1..}).toArray(function(error, result) {\n\t\t\tif (error) {\n\t\t\t  console.log(err); \n\t\t\t}\n\t\t\telse {\n\t\t\t\t//do something with result\n\t\t\t}\n\t\t});\n\t  }\n\n\t  db.collection('matches', function(error, collection) {\n\t\tif (error) callback(error);\n\t\telse callback(null, collection);\n\t  });\n\t}\n\n\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\tFor another example see in test0.js in tests.\n\n\t`Obvious 'thing' is optionalCallBack doesn't use the MAL class but rather requires the user to get the collection ref \n\tand then preform the method call using node-mongodb-native directly for both.`\n\n3. Function calls\n--------------------------------\n\n\tFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\n\tThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\t\n\t//List of calls available in v0.2\n\t.find(collectionName, query, fields, options, callback)\n\t.findOne(collectionName, query, callback) \t\n\t.insert(collection_Name, query, options, callback) \n\t.save = function(collectionName,obj, callback)\n\t.update = function(collectionName, criteria, update, options, callback) \n\t.remove = function(collectionName, criteria, callback)\n\t.findAndModify = function(collection_Name, criteria, sort, update, options, callback)\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t.streamPipe = function(collectionName, query, fields, options, wrStream)\n\t.streamEvents = function(collectionName, query, fields, options, xStream)\n\n4. Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//create a readable stream\n\t\tvar dbStream = new stream.Stream();\n\t\tdbStream.readable = true;\n\t\t//pass it into the streamEvents function\n\t\tdbManager.streamEvents('Col1',dbStream);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\t\t//and listen on events\n\t\tdbStream.on('data', function(data) {\n\t\t  res.write('data: ' + JSON.stringify(data) + '\\r\\n\\r\\n');\n\t\t});\n\t\tdbStream.on('end', function() {\n\t\t  console.log('ended');\n\t\t});\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Add mapReduce and other calls\n\t4. Take it from there.\n","_id":"mal@0.2.0","dist":{"shasum":"dda343f81169b2a85e45ccf812c75cc7e99212eb","tarball":"https://registry.npmjs.org/mal/-/mal-0.2.0.tgz","integrity":"sha512-jEg/VAxN+F4uYK6MXXltnlC40ADwkS+h2YO+kx43jbgAbcTDqzvhVWihMXcRypdx03E7FsLdynC981m0tNphQQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCdrQPWmqvQNTejKAhfKeg/j4lWLmv+byTbMKdDshexGQIgHSrNYKeQkLoorci2LJ9++iMPJggtRgQ73oqfgRWlb7M="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.2.1":{"name":"mal","version":"0.2.1","description":"MAL: MongoDB Access Layer. A simple convienence data access layer over the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB","convenience methods for mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"@daithi44","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.1.11"},"engines":{"node":">= 0.8.10"},"readme":"MAL (Simple MongoDB Access Layer) v0.2.1\n======================================\n\n\nConvenience methods for access a connecting to, authenticating and querying against a MongoDB instance in Node.\n---------------------------------------------------------------------------------------------------------------\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tTO USE: \n\n\t\t$ npm install mal\n\n\t\tvar MAL = rquire('mal').MAL\n\n\t\tvar dbsettings = {\n\t\t\thost: 'host ip or name',\n\t\t\tport: port number,\n\t\t\tdb: 'database name',\n\t\t\toptions: {auto_reconnect: true},\n\t\t\tusername: '...',\n\t\t\tpassword: '...'\n\t\t};\n\n\n\t\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\t\t[full details available @ ](https://github.com/daithiw44/MAL/blob/master/readme.markdown)\n\n\n","_id":"mal@0.2.1","dist":{"shasum":"5535a36036a4d6eb03de68945a57aea772c970bb","tarball":"https://registry.npmjs.org/mal/-/mal-0.2.1.tgz","integrity":"sha512-1FOeXdOVtc/wGFmW03uTdAMsMCG+q4IozTwHeSVvq4Ek7Cu+o+Yyq9t4Qr0h5z6iCzDTnAB7eOV1BplUP1am1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDA0OZQ3tnox5AJxAIyAoRJPzIRlFLqw+NzxAzIGmg29AIhAIeAHlubvecWif7UdnLMLN3ii074zO2gGnui/kFXUxF8"}]},"_npmVersion":"1.1.62","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.2.2":{"name":"mal","version":"0.2.2","description":"MAL: MongoDB Access Layer. A simple convienence data access layer over the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB","convenience methods for mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"@daithi44","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.1.11"},"engines":{"node":">= 0.8.10"},"readme":"MAL (Simple MongoDB Access Layer) v0.2.1\n======================================\n\n\nConvenience methods for access a connecting to, authenticating and querying against a MongoDB instance in Node.\n---------------------------------------------------------------------------------------------------------------\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tTO USE: \n\n\t\t$ npm install mal\n\n\t\tvar MAL = rquire('mal').MAL\n\n\t\tvar dbsettings = {\n\t\t\thost: 'host ip or name',\n\t\t\tport: port number,\n\t\t\tdb: 'database name',\n\t\t\toptions: {auto_reconnect: true},\n\t\t\tusername: '...',\n\t\t\tpassword: '...'\n\t\t};\n\n\n\t\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\t\t[full details available @ ](https://github.com/daithiw44/MAL/blob/master/readme.markdown)\n\n\n","_id":"mal@0.2.2","dist":{"shasum":"8b7c912bb269f3d21bee22836330d0fd0e3dada2","tarball":"https://registry.npmjs.org/mal/-/mal-0.2.2.tgz","integrity":"sha512-7+Trl04pEuElkewV+vKtb+w5LnXljMjT3/bIGj0aUHC++ZEpXIrSj4wfCy8jP/Eo479RsurlAcCkzc5Q4gqjnQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCyGEKRMQy9HT49AwIkVPC3V/U9qBAMEh6hbuHTg4Li6AIgQ6SOhgfyymjDegzpUoJUlpnyMyMGDyH2sRPnpJnpzcc="}]},"_npmVersion":"1.1.62","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.2.3":{"name":"mal","version":"0.2.3","description":"MAL: MongoDB Access Layer. A simple convienence data access layer over the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB","convenience methods for mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"@daithi44","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.1.11"},"engines":{"node":">= 0.8.10"},"readme":"MAL (Simple MongoDB Access Layer) v0.2.3\n======================================\n\n\nConvenience methods for access a connecting to, authenticating and querying against a MongoDB instance in Node.\n---------------------------------------------------------------------------------------------------------------\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tTO USE: \n\n\t\t$ npm install mal\n\n\t\tvar MAL = rquire('mal').MAL\n\n\t\tvar dbsettings = {\n\t\t\thost: 'host ip or name',\n\t\t\tport: port number,\n\t\t\tdb: 'database name',\n\t\t\toptions: {auto_reconnect: true},\n\t\t\tusername: '...',\n\t\t\tpassword: '...'\n\t\t};\n\n\n\t\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\t\t[full details available @ ](https://github.com/daithiw44/MAL/blob/master/readme.markdown)\n\n\n","_id":"mal@0.2.3","dist":{"shasum":"eaed04170b9d422014301a247093b2a936612375","tarball":"https://registry.npmjs.org/mal/-/mal-0.2.3.tgz","integrity":"sha512-dvMe5SzHwgvKTF2ROoczJbpWhUv54y9fU6J8VwTRwxjTQwg19pBbX6HOD+oxTtVvoDrWGSZhRYk15T9ydZPGXA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDUApD8uazJymLbnkC8tqRkY9S5c/vYPdaau1drCL9iAgIhAKzuq5Eba4135EyKoJaVSr1aOELa++6vIqcUivWMSS9L"}]},"_npmVersion":"1.1.62","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.3.0":{"name":"mal","version":"0.3.0","description":"MAL MongoDB Access Layer. A simple data access for MongoDB using the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB"],"repository":{"type":"git","url":""},"contributors":[{"name":"David Winders","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.2.14","request":"2.11.4"},"engines":{"node":">= 0.10.0"},"readme":"MAL (Simple MongoDB Access Layer) v0.3.0\n======================================\n\n\nConvenience methods for accessing and connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\nNOW USES NODE v0.10 and mongodb-1.2.14, to cater for process.nextTick see changelog.\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\n0. npm\n--------------------------------\nnpm install mal\n\nvar MAL = require('mal').MAL;\n\n1. Create a dbSettings object\n--------------------------------\n\t//example dbSettings Object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n\n2. var dbManager = new MAL(dbsettings, optionalCallback);\n----------------------------------------------------------------\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n\n\tvar dbManager = new MAL(dbsettings);\n\n\tCallback required\n\t------------------\n\n\t//example\n\n\tfunction optionalCallback(db){\n\t  var callback = function(err, collection){\n\t\tcollection.find({status:1}, {id:1..}).toArray(function(error, result) {\n\t\t\tif (error) {\n\t\t\t  console.log(err); \n\t\t\t}\n\t\t\telse {\n\t\t\t\t//do something with result\n\t\t\t}\n\t\t});\n\t  }\n\n\t  db.collection('matches', function(error, collection) {\n\t\tif (error) callback(error);\n\t\telse callback(null, collection);\n\t  });\n\t}\n\n\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\tFor another example see in test0.js in tests.\n\n\t`Obvious 'thing' is optionalCallBack doesn't use the MAL class but rather requires the user to get the collection ref \n\tand then preform the method call using node-mongodb-native directly for both.`\n\n3. Function calls\n--------------------------------\n\n\tFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\n\tThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\t\n\t//List of calls available in v0.2\n\t.find(collectionName, query, fields, options, callback)\n\t.findOne(collectionName, query, callback) \t\n\t.insert(collection_Name, query, options, callback) \n\t.save = function(collectionName,obj, callback)\n\t.update = function(collectionName, criteria, update, options, callback) \n\t.remove = function(collectionName, criteria, callback)\n\t.findAndModify = function(collection_Name, criteria, sort, update, options, callback)\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t.streamPipe = function(collectionName, query, fields, options, wrStream)\n\t.streamEvents = function(collectionName, query, fields, options, xStream)\n\n4. Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//pass http response object as stream, or store the response object and pass in the stores response\n\t\tdbManager.streamEvents('Col1',res);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\tc) stream to websockets with .streamPipe\n\t\tsee websockets in examples using shoe and browserify.\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Add mapReduce and other calls\n\t4. Take it from there.\n\n6. Changelog.\n--------------------------------\n\n\t1. Node server may be up before DBConnection, depending on how MAL is used. MAL will now buffer the db requests while the connection is being established and execut them once the connection is live.\n\t2. Node changes to streams in v0.10, streams for server sent events are piped and v0.3.0 requires node v0.10.\n","readmeFilename":"readme.markdown","_id":"mal@0.3.0","dist":{"shasum":"6c52d897dd6817632c529eeb6c4e0626afd9b204","tarball":"https://registry.npmjs.org/mal/-/mal-0.3.0.tgz","integrity":"sha512-v4vi4obpcJ4/6ptCOnawyUFkm4QyaoEba2PEDxCflBYhu+NApc69tTbRSJPrWUL2NAW+H9ENPQ+Q1Yt55LwCjw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID1YLpBIJuuaZHQrEdCxnkDC0vHN49Ecw8IvCsdv2kcKAiAV0swC4m0s1jpq2Qnlpzq4vbnaiGuv9Cn3gcIMj6S7lw=="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.3.1":{"name":"mal","version":"0.3.1","description":"MAL MongoDB Access Layer. A simple data access for MongoDB using the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"David Winders","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.2.14","request":"2.11.4"},"engines":{"node":">= 0.10.0"},"readme":"MAL (Simple MongoDB Access Layer) v0.3.0\n======================================\n\n\nConvenience methods for accessing and connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\nNOW USES NODE v0.10 and mongodb-1.2.14, to cater for process.nextTick see changelog.\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\n0. npm\n--------------------------------\nnpm install mal\n\nvar MAL = require('mal').MAL;\n\n1. Create a dbSettings object\n--------------------------------\n\t//example dbSettings Object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n\n2. var dbManager = new MAL(dbsettings, optionalCallback);\n----------------------------------------------------------------\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n\n\tvar dbManager = new MAL(dbsettings);\n\n\tCallback required\n\t------------------\n\n\t//example\n\n\tfunction optionalCallback(db){\n\t  var callback = function(err, collection){\n\t\tcollection.find({status:1}, {id:1..}).toArray(function(error, result) {\n\t\t\tif (error) {\n\t\t\t  console.log(err); \n\t\t\t}\n\t\t\telse {\n\t\t\t\t//do something with result\n\t\t\t}\n\t\t});\n\t  }\n\n\t  db.collection('matches', function(error, collection) {\n\t\tif (error) callback(error);\n\t\telse callback(null, collection);\n\t  });\n\t}\n\n\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\tFor another example see in test0.js in tests.\n\n\t`Obvious 'thing' is optionalCallBack doesn't use the MAL class but rather requires the user to get the collection ref \n\tand then preform the method call using node-mongodb-native directly for both.`\n\n3. Function calls\n--------------------------------\n\n\tFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\n\tThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\t\n\t//List of calls available in v0.2\n\t.find(collectionName, query, fields, options, callback)\n\t.findOne(collectionName, query, callback) \t\n\t.insert(collection_Name, query, options, callback) \n\t.save = function(collectionName,obj, callback)\n\t.update = function(collectionName, criteria, update, options, callback) \n\t.remove = function(collectionName, criteria, callback)\n\t.findAndModify = function(collection_Name, criteria, sort, update, options, callback)\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t.streamPipe = function(collectionName, query, fields, options, wrStream)\n\t.streamEvents = function(collectionName, query, fields, options, xStream)\n\n4. Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//pass http response object as stream, or store the response object and pass in the stores response\n\t\tdbManager.streamEvents('Col1',res);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\tc) stream to websockets with .streamPipe\n\t\tsee websockets in examples using shoe and browserify.\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Add mapReduce and other calls\n\t4. Take it from there.\n\n6. Changelog.\n--------------------------------\n\n\t1. Node server may be up before DBConnection, depending on how MAL is used. MAL will now buffer the db requests while the connection is being established and execut them once the connection is live.\n\t2. Node changes to streams in v0.10, streams for server sent events are piped and v0.3.0 requires node v0.10.\n","readmeFilename":"readme.markdown","_id":"mal@0.3.1","dist":{"shasum":"9a62866a1f707d95b540d948ce5286de38c18680","tarball":"https://registry.npmjs.org/mal/-/mal-0.3.1.tgz","integrity":"sha512-oBqofsupx/qC+fBsmb/j+P67RWWsTWYm6FGrCaVrcjXl+/5XbOtrcSLIEcvJHefggxTNCvaRJf2BDQ9WzK62MQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHdx0MafGYdO1QtP27/XfXcs4Ae5bxhz8cSrS25rT+lzAiBvoy4AFPloSWSUmHH2bOmt6Wu5LFdR+Iw23xiG9OEClg=="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.3.3":{"name":"mal","version":"0.3.3","description":"MAL MongoDB Access Layer. A simple data access for MongoDB using the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"David Winders","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.2.14","request":"2.11.4"},"engines":{"node":">= 0.10.0"},"readme":"MAL (Simple MongoDB Access Layer) v0.3.3\n======================================\n\n\nConvenience methods for accessing and connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\nMAL 0.3.3 NOW USES NODE v0.10 and mongodb-1.2.14, to cater for process.nextTick, and buffers requests while server connects to DB. see changelog.\n\n-For node < 0.10 use MAL  0.2.3\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\n0. npm\n--------------------------------\nnpm install mal\n\nvar MAL = require('mal').MAL;\n\n1. Create a dbSettings object\n--------------------------------\n\t//example dbSettings Object.\n``` js\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n```\n\n2. var dbManager = new MAL(dbsettings, optionalCallback);\n----------------------------------------------------------------\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n``` js\n\n\tvar dbManager = new MAL(dbsettings);\n```\n\n\tCallback required\n\t------------------\n``` js\n\t//example (see test3.js)\n\tvar obj = {\n\t  b: 'connected',\n\t  t: new Date()\n\t};\n\tvar dbManager = new MAL(dbsettings, function(){\n\t  dbManager.insert('Tests', obj, {},function(err,result) {\n\t\tdbManager.find('Tests',{ b: 'connected'},function(err,result) {\n\t\t  console.log(result);\n\t\t});\n\t  });\n\t});\n``` \n\n\tAs of MAL 0.3.0 MAL buffers requests until a connection is establish, and then plays through the requests one the db connection status is 'connected'.\n\n\toptionalCallback could also be a function non db related for a example a node process.\n``` js\n\n\tvar dbManager = new MAL(dbsettings, function(){\n\t\thttp.createServer(function (req, res) {\n\t\t  res.writeHead(200, {'Content-Type': 'text/plain'});\n\t\t  res.end('Hello World\\n');\n\t\t}).listen(1337, '127.0.0.1');\n\t\tconsole.log('Server running at http://127.0.0.1:1337/');\n\t});\n``` \n\n3. Function calls\n--------------------------------\n\n\tFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\n\tThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n``` js\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\t\n\t//List of calls available in v0.2\n\t.find(collectionName, query, fields, options, callback)\n\t.findOne(collectionName, query, callback) \t\n\t.insert(collection_Name, query, options, callback) \n\t.save = function(collectionName,obj, callback)\n\t.update = function(collectionName, criteria, update, options, callback) \n\t.remove = function(collectionName, criteria, callback)\n\t.findAndModify = function(collection_Name, criteria, sort, update, options, callback)\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t.streamPipe = function(collectionName, query, fields, options, wrStream)\n\t.streamEvents = function(collectionName, query, fields, options, xStream)\n``` \n\n4. Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//pass http response object as stream, or store the response object and pass in the stores response\n\t\tdbManager.streamEvents('Col1',res);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\tc) stream to websockets with .streamPipe\n\t\tsee websockets in examples using shoe and browserify.\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Add mapReduce and other calls\n\t4. Take it from there.\n\n6. Changelog.\n--------------------------------\n\n\t1. Node server may be up before DBConnection, depending on how MAL is used. MAL will now buffer the db requests while the connection is being established and execut them once the connection is live.\n\t2. Node changes to streams in v0.10, streams for server sent events are piped and v0.3.0 requires node v0.10.\n","readmeFilename":"readme.markdown","_id":"mal@0.3.3","dist":{"shasum":"29ba72196a95ba3fa22c8845729a0e524b24d6d2","tarball":"https://registry.npmjs.org/mal/-/mal-0.3.3.tgz","integrity":"sha512-R0ecIpSfADHO1/ZTalzY02L1yKx8qwvQ9TYdkLJbrtDkmt1YP+YGKeWZ5EVyWhN15tNdkhB3s7V5FiDB5Qw6Qw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFvnXK0p49skwMyRDeoc2WZKKNMOW9DHBEe3MuU6lRJsAiEAz/XEpku82jd7nTquwBq4d/Oblku6F1NgmFJgXpaHcP8="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.3.4":{"name":"mal","version":"0.3.4","description":"MAL MongoDB Access Layer. A simple data access for MongoDB using the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","Data Access layer","streaming from mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"David Winders","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.2.14","request":"2.11.4"},"engines":{"node":">= 0.8.0"},"readme":"MAL (Simple MongoDB Access Layer) v0.3.4\n======================================\n\n\nConvenience methods for accessing and connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\nMAL 0.3.3  uses mongodb-1.2.14, to cater for process.nextTick, and buffers requests while server connects to DB. see changelog.\n\n-For node > 0.8.0\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\n0. npm\n--------------------------------\nnpm install mal\n\nvar MAL = require('mal').MAL;\n\n1. Create a dbSettings object\n--------------------------------\n\t//example dbSettings Object.\n``` js\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n```\n\n2. var dbManager = new MAL(dbsettings, optionalCallback);\n----------------------------------------------------------------\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n``` js\n\n\tvar dbManager = new MAL(dbsettings);\n```\n\n\tCallback required\n\t------------------\n``` js\n\t//example (see test3.js)\n\tvar obj = {\n\t  b: 'connected',\n\t  t: new Date()\n\t};\n\tvar dbManager = new MAL(dbsettings, function(){\n\t  dbManager.insert('Tests', obj, {},function(err,result) {\n\t\tdbManager.find('Tests',{ b: 'connected'},function(err,result) {\n\t\t  console.log(result);\n\t\t});\n\t  });\n\t});\n``` \n\n\tAs of MAL 0.3.0 MAL buffers requests until a connection is establish, and then plays through the requests one the db connection status is 'connected'.\n\n\toptionalCallback could also be a function non db related for a example a node process.\n``` js\n\n\tvar dbManager = new MAL(dbsettings, function(){\n\t\thttp.createServer(function (req, res) {\n\t\t  res.writeHead(200, {'Content-Type': 'text/plain'});\n\t\t  res.end('Hello World\\n');\n\t\t}).listen(1337, '127.0.0.1');\n\t\tconsole.log('Server running at http://127.0.0.1:1337/');\n\t});\n``` \n\n3. Function calls\n--------------------------------\n\n\tFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\n\tThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n``` js\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\t\n\t//List of calls available in v0.2\n\t.find(collectionName, query, fields, options, callback)\n\t.findOne(collectionName, query, callback) \t\n\t.insert(collection_Name, query, options, callback) \n\t.save = function(collectionName,obj, callback)\n\t.update = function(collectionName, criteria, update, options, callback) \n\t.remove = function(collectionName, criteria, callback)\n\t.findAndModify = function(collection_Name, criteria, sort, update, options, callback)\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t.streamPipe = function(collectionName, query, fields, options, wrStream)\n\t.streamEvents = function(collectionName, query, fields, options, xStream)\n``` \n\n4. Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//pass http response object as stream, or store the response object and pass in the stores response\n\t\tdbManager.streamEvents('Col1',res);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\tc) stream to websockets with .streamPipe\n\t\tsee websockets in examples using shoe and browserify.\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Add mapReduce and other calls\n\t4. Take it from there.\n\n6. Changelog.\n--------------------------------\n\n\t1. Node server may be up before DBConnection, depending on how MAL is used. MAL will now buffer the db requests while the connection is being established and execut them once the connection is live.\n\t2. Node changes to streams in v0.10, streams for server sent events are piped and v0.3.0 requires node v0.10.\n","readmeFilename":"readme.markdown","_id":"mal@0.3.4","dist":{"shasum":"e7a72e14aa45df79f4be2e1cd8d755d423de4d8e","tarball":"https://registry.npmjs.org/mal/-/mal-0.3.4.tgz","integrity":"sha512-eKrNRbe9Pk8w5RXFiFOeRM9/TQajo/vVgsvbXyz8jL0SgQWhqQKd7GYEApbupA+90VtPALYmBuBQIeReQ0jW7g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBf2590ecNG9hOVw0JkLNwfZtzpgJdCKL97Z2CmbnqNPAiAeSZSSk6v74Lecab6ZJ07rXYeViDJLQLS5cs38QoGeLg=="}]},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"directories":{}},"0.4.0":{"name":"mal","version":"0.4.0","description":"MAL MongoDB Access Layer. A MongoDB wrapper using the native-node-driver","author":{"name":"@daithi44"},"keywords":["mongoDB","mongoDB wrapper","streaming from mongoDB"],"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"},"contributors":[{"name":"David Winders","email":"david.winders@gmail.com"}],"dependencies":{"JSONStream":"0.4.2","mongodb":"1.2.14","request":"2.11.4"},"engines":{"node":">= 0.8.0"},"readme":"### MongoDB Wrapper - MAL (MongoDB Access Layer) v0.4.0\n======================================\n\n\n#### Convenience methods for accessing and connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\n##### What MAL is:\nMal just makes it easier to open, authenicate aconnect to a db. It should make it easier to connect to collections and preform any of the tasks an app would need to perform agaisnt a mongoDB instance.If you database server goes down or is delayed connecting MAL will buffer requests while server connects, reconnections to DB.\n\n#####  What MAL isn't is:\nAt the moment by choice MAL won't directly, (but could ...see univeralMethod below), create your indexes, reIndex it won't drop collections, I normaly have them done before hand or directly in the db, if you really need them\n\n\tMAL.universalMethod('method',arguments);\n\teg. MAL.universalMethod('createIndex',['collection_name',fieldOrSpec, {options}, callback]);\n\tsee example in geo for use of universalMethod instead of ensureIndex.\n\n\n-For node > 0.8.0\n\n#### Examples\n[mal examples](https://github.com/daithiw44/MAL/tree/master/examples)\n\n#### Tests\n[mal tests](https://github.com/daithiw44/MAL/tree/master/tests)\n\n#### MAL\n\nMAL provides an easy way to perform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\n#### Install\n\nnpm\n--------------------------------\nnpm install mal\n\n\n#### Require\nvar MAL = require('mal').MAL;\n\n#### Create a dbSettings object with Authentication if required.\n--------------------------------\n\texample dbSettings Objects.\n\n\t//Authenticate\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n\n#### Fire it up\n----------------------------------------------------------------\n\nvar dbManager = new MAL(dbsettings, optionalCallback);\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n\n\tvar dbManager = new MAL(dbsettings);\n```\n\n\tCallback required\n\t------------------\n\t//example (see test3.js)\n\tvar obj = {\n\t  b: 'connected',\n\t  t: new Date()\n\t};\n\tvar dbManager = new MAL(dbsettings, function(){\n\t  dbManager.insert('Tests', obj, {},function(err,result) {\n\t\tdbManager.find('Tests',{ b: 'connected'},function(err,result1) {\n\t\t  console.log(result1);\n\t\t});\n\t  });\n\t});\n``` \noptionalCallback could also be a function non db related for a example a node process.\n\n\n\tvar dbManager = new MAL(dbsettings, function(){\n\t\thttp.createServer(function (req, res) {\n\t\t  res.writeHead(200, {'Content-Type': 'text/plain'});\n\t\t  res.end('Hello World\\n');\n\t\t}).listen(1337, '127.0.0.1');\n\t\tconsole.log('Server running at http://127.0.0.1:1337/');\n\t});\n\n\n#### Buffers requests if there is no connection established.\n----------------------------------------------------------------\n\nAs of MAL 0.3.0 MAL buffers requests until a connection is establish, and then plays through the requests one the db connection status is 'connected'.\n\nWhere I use buffers is when I have a server whos job it is to speak with a database. Say the database is hosted at Mongolab for example. Typical upNode example a client connects with the server firing in requests…\n\n* server goes down\n* upNode client buffers til the server comes back up\n* server comes up but hasn't established a DB connection and the client fires all its buffered requests\n* In that senario all the requests are lost from the client as the server can't act on them as the db connection hasn't been established.\n* MAL takes these requests and buffers them until the connection with Mongolab is etablished and then plays them through.\n\n\n#### Function calls\n--------------------------------\n\nFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\nThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\n\t\n#### List of calls available in v0.4\n\tMALinstance.\n\t*find(collectionName, query, fields, options, callback)\n\t*findOne(collectionName, query, callback) \t\n\t*insert(collection_Name, query, options, callback) \n\t*save(collectionName,obj, callback)\n\t*update(collectionName, criteria, update, options, callback) \n\t*remove(collectionName, criteria, callback)\n\t*findAndModify(collection_Name, criteria, sort, update, options, callback)\n\t*findAndRemove(collection_Name, criteria, sort, options, callback)\n\t*ensureIndex(collection_Name, ..as mongodb spec\n\t*count(collection_Name, ..as mongodb spec\n\t*distinct(collection_Name, ..as mongodb spec\n\t//Aggregate Framework.\n\t*aggregate(collection_Name, criteria, criteria....,options,callback);\n\t//geo Stuff\n\t*geoNear(collection_Name, x, y, options, callback);\n\t*geoHaystackSearch(collection_Name, x, y, options, callback);\n\t//MapReduce\n\t*mapReduce(collection_Name, map, reduce, options, callback);\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t*streamPipe(collectionName, query, fields, options, wrStream)\n\t*streamEvents(collectionName, query, fields, options, xStream)\n\n#### Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( Server side Events from Node/MongoDB... see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//pass http response object as stream, or store the response object and pass in the stores response\n\t\tdbManager.streamEvents('Col1',res);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\tc) stream to websockets with .streamPipe\n\t\tsee websockets in examples using shoe and browserify.\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Replica Sets\n\t4. GridFS\n\n6. Changelog.\n--------------------------------\n\n\t1. v0.3.4 Node server may be up before DBConnection, depending on how MAL is used. MAL will now buffer the db requests while the connection is being established and execut them once the connection is live.\n\t2. v0.3.4 Node changes to streams in v0.10, streams for server sent events are piped.\n\t3. v0.4.0 Aggregate, mapreduce, geoNear, geoHaystackSearch.\n\n\n","readmeFilename":"readme.markdown","_id":"mal@0.4.0","dist":{"shasum":"af15c4094184d1fe3ee18cde263bf9f63f166c62","tarball":"https://registry.npmjs.org/mal/-/mal-0.4.0.tgz","integrity":"sha512-DS9E9/aXFyrZiX4KGFAGrQnzEanCStnnLQ3FLo0Y8vs+oMY7Wcy9GKeho8Mw3xfwGge8KObimGkVIHiGIymgNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGV997dDGqAoeMCZ4KzhQImML4PYpWcy7sCcRLnIeZXXAiB1TIq22iJQNkuqRIhfoEm6QFtm72D9Q3mxPICa/yy/ew=="}]},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"daithi44","email":"david.winders@gmail.com"},"maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}]}},"readme":"MAL (Simple MongoDB Access Layer) v0.2\n======================================\n\n\nConvenience methods for access a connecting to, authenticating and querying against a MongoDB instance in Node.\n--------------------------------------------------------------------------------------------\n\nMAL provides an easy way to preform operations on a MongoDB instance.\n[mongodb / node-mongodb-native](https://github.com/mongodb/node-mongodb-native) -- `sits on mongodb / node-mongodb-native function calls`\n\n\tAs a general rule function calls take the format of ('collectionname', ...>>> same rules for params as node-mongodb-native);\n\t*exceptions being the two streams calls where the last parameters are always the writebale stream for streamPipe \n\t\tor readable stream for streamEvents.\n\t** no callback if none is desired but set {safe:false} etc.. same as node-mongodb-native.\n\nTo create and instance of MAL\n\n1. Create a dbSettings object\n--------------------------------\n\t//example dbSettings Object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true},\n\t\tusername: '...',\n\t\tpassword: '...'\n\t};\n\n\t//username and password are required only if there is authentication, \n\t//if there is no authentication required remove the properties from the object.\n\n\tvar dbsettings = {\n\t\thost: 'host ip or name',\n\t\tport: port number,\n\t\tdb: 'database name',\n\t\toptions: {auto_reconnect: true}\n\t};\n\n2. var dbManager = new MAL(dbsettings, optionalCallback);\n----------------------------------------------------------------\n\toptionalCallback is a function that is takes an connected mongoDB server as a parameter.\n\n\tNo CallBack required.\n\t----------------------\n\n\tvar dbManager = new MAL(dbsettings);\n\n\tCallback required\n\t------------------\n\n\t//example\n\n\tfunction optionalCallback(db){\n\t  var callback = function(err, collection){\n\t\tcollection.find({status:1}, {id:1..}).toArray(function(error, result) {\n\t\t\tif (error) {\n\t\t\t  console.log(err); \n\t\t\t}\n\t\t\telse {\n\t\t\t\t//do something with result\n\t\t\t}\n\t\t});\n\t  }\n\n\t  db.collection('matches', function(error, collection) {\n\t\tif (error) callback(error);\n\t\telse callback(null, collection);\n\t  });\n\t}\n\n\tvar dbManager = new MAL(dbsettings, optionalCallback);\n\n\tFor another example see in test0.js in tests.\n\n\t`Obvious 'thing' is optionalCallBack doesn't use the MAL class but rather requires the user to get the collection ref \n\tand then preform the method call using node-mongodb-native directly for both.`\n\n3. Function calls\n--------------------------------\n\n\tFunction calls to the MAL instance follow the same pattern as node-mongodb-native the exception being \n\tthat all the first paramater is the name of the collection being queried.\n\n\tThe first parameter is always the collection name, followed by parameters expected by node-mongodb-native\n\n\texample:\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\tdbManager.find ('col1', {name : 'name'}, {_id:0}, function(err,result){...}); \n\t\n\t//List of calls available in v0.2\n\t.find(collectionName, query, fields, options, callback)\n\t.findOne(collectionName, query, callback) \t\n\t.insert(collection_Name, query, options, callback) \n\t.save = function(collectionName,obj, callback)\n\t.update = function(collectionName, criteria, update, options, callback) \n\t.remove = function(collectionName, criteria, callback)\n\t.findAndModify = function(collection_Name, criteria, sort, update, options, callback)\n\t// for Stream methods last parameters must be the writable or readable streams.\n\t.streamPipe = function(collectionName, query, fields, options, wrStream)\n\t.streamEvents = function(collectionName, query, fields, options, xStream)\n\n4. Streaming Functionality.\n--------------------------------\n\t\n\tMAL provides two streaming methods. (see examples).\n\t\n\t//Assume\n\tvar dbManager = new MAL(dbsettings);\n\n\t a) streamPipe. (see stream in examples)\n\t \t//function(collectionName, query, fields, options, wrStream) {...\n\t\t// the first argument is always a collectionName\n\t\t// the last\n\t \tdbManager.streamPipe('col1',stream);\n\t\t//this calll will return everything from 'col1' \n\t\t//and pipe the results to wrStream where wrStream is a writable stream like response or a tcp socket.\n\n\t b) streamEvents.( see sse in examples);\n\t \t//lets say we are streaming to serversent events.\n\t\t//create a readable stream\n\t\tvar dbStream = new stream.Stream();\n\t\tdbStream.readable = true;\n\t\t//pass it into the streamEvents function\n\t\tdbManager.streamEvents('Col1',dbStream);\n\t\tres.writeHead(200, {\n\t\t  'Content-Type': 'text/event-stream',\n\t\t  'Cache-Control': 'no-cache',\n\t\t  'Connection': 'keep-alive'\n\t\t});\n\t\t//flush headers\n\t\tres.write('');\n\t\t//and listen on events\n\t\tdbStream.on('data', function(data) {\n\t\t  res.write('data: ' + JSON.stringify(data) + '\\r\\n\\r\\n');\n\t\t});\n\t\tdbStream.on('end', function() {\n\t\t  console.log('ended');\n\t\t});\n\nsee 'server sent events' example on [cloudfoundry nodejs using a mongolab mongoDB instance](http://mongodbstreamdemo.cloudfoundry.com/)\nstreaming 4.8mb of tweets to the browser with Server Sent Events.\n\nTo populated data, pulled tweets from a twitter account that has volume tweets and stuck them in a mongoDB at mongolab.\n\n5. ToDo.\n--------------------------------\n\n\t1. Write more tests\n\t2. Write examples\n\t3. Add mapReduce and other calls\n\t4. Take it from there.\n","maintainers":[{"name":"daithi44","email":"david.winders@gmail.com"}],"time":{"modified":"2022-06-19T15:39:36.025Z","created":"2012-11-07T21:45:04.911Z","0.2.0":"2012-11-07T21:45:17.707Z","0.2.1":"2012-11-07T22:14:12.569Z","0.2.2":"2012-11-13T20:43:24.761Z","0.2.3":"2012-12-05T10:32:14.823Z","0.3.0":"2013-04-01T14:28:10.744Z","0.3.1":"2013-04-01T14:57:56.255Z","0.3.3":"2013-04-01T16:29:15.774Z","0.3.4":"2013-04-03T11:14:11.908Z","0.4.0":"2013-04-05T13:15:47.196Z"},"author":{"name":"@daithi44"},"repository":{"type":"git","url":"https://github.com/daithiw44/MAL"}}