Skip to content

gulf/gulf-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gulf-mongodb

gulf storage adapter for mongodb

Compatible with gulf v4, only. Writing a storage adapter for gulf v5 is super easy and you're much more flxible than taking an opinionated one like this.

Install

npm install gulf-mongodb

(gulf-mongodb was written against [email protected])

Usage

var gulf = require('gulf')
var mongoose = require('mongoose')
var MongoDBAdapter = require('gulf-mongodb')

var dbConnection = mongoose.createConnection('mongodb://localhost/my_database')
var mongoAdapter = new MongoDBAdapter(dbConnection)
gulf.Document.create(mongoAdapter, ottype, 'initial contents', function(er, doc) {
  if(er) throw er
  net.createServer(function(stream) {
    stream.pipe(doc.slaveLink()).pipe(stream)
  }).listen(5314)
})

Or, if the document already exists:

var gulf = require('gulf')
var mongoose = require('mongoose')
var MongoDBAdapter = require('gulf-mongodb')

var dbConnection = mongoose.createConnection('mongodb://localhost/my_database')
var mongoAdapter = new MongoDBAdapter(dbConnection)
gulf.Document.load(mongoAdapter, ottype, docId, function(er, doc) {
  if(er) throw er
  net.createServer(function(stream) {
    stream.pipe(doc.slaveLink()).pipe(stream)
  }).listen(5314)
})

Legal

(c) 2015 by Marcel Klehr

GNU Lesser General Public License

About

Gulf storage adapter for mongodb

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •