Skip to content

recidive/prana-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Prana MongoDB Storage

MongoDB Storage for the Prana Framework.

Installation

$ npm install prana-mongodb

Basic usage

var Prana = require('prana');
var MongoDBStorage = require('prana-mongodb');
var MongoClient = require('mongodb').MongoClient;

// Create a prana application.
var application = new Prana();

// Connect to MongoDB server.
MongoClient.connect('mongodb://localhost/database', function(error, database) {

  // Add the 'mongodb' storage.
  application.storage('mongodb', {
    controller: MongoDBStorage,
    database: database
  });

  var Cache = application.type('cache', {
    title: 'Cache',
    description: 'A very simple key/value cache storage mechanism.',
    path: 'cache',
    // Set storage for this type to 'mongodb'.
    storage: 'mongodb'
  });

  // Create a cache item.
  var cache = new Cache({
    name: 'some-cache',
    value: 'some-cache-value'
  });

  // Save item to MongoDB.
  cache.save(function(error, item) {
    console.log('Added item');
    console.log(item);

    // Optionally close MongoDB connection to end the process.
    database.close();
  });

});

About

MongoDB Storage Engine for the Prana Framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published