GithubHelp home page GithubHelp logo

pronto-mongodb's Introduction

Pronto-MongoDB: MongoDB drivers for Pronto.js

Pronto.js is a toolkit for building component-based evented systems in Node.js. Using the design pattern commonly called the Chain of Command, sequences of tasks are tied together and executed.

This project provides commands (individual components) for working with MongoDB.

Example

Here is an example of adding a series of MongoDB operations to a route in Pronto:

mongo = require('pronto-mongodb');
register.route('test')
  // Open a connection to a MongoDB.
  .does(mongo.Use, 'use').using('dbName', 'prontoTest')
  
  // Get (or create) a collection called 'narf'.
  .does(mongo.GetCollection, 'narf').using('dbName', 'prontoTest').using('collection', 'narf')
  
  // Insert a document into the collection.
  .does(mongo.Insert, 'doc1').using('collection').from('cxt:narf').using('data', {'doc': 1})
  
  // Add another document (using save, which is insert-or-update).
  .does(mongo.Save, 'doc2').using('collection').from('cxt:narf').using('data', {'doc': 2})
  
  // Find a single document that matches the specified filter.
  .does(mongo.FindOne, 'looky').using('collection').from('cxt:narf').using('filter', {'doc': 1})
  
  // Normally, we would do something useful here.... but we're not going to.
  
  // Drop the entire 'narf' collection.
  .does(mongo.Drop).using('collection', 'narf').using('dbName', 'prontoTest')
  
  // Close the database.
  .does(mongo.Close).using('dbName', 'prontoTest')
;

The above shows how Pronto-MongoDB commands can be used within a Pronto application. The example is simple, but most of the commands have many available parameters, allowing you to construct elaborate applications.

MongoDB Features

Q: How do you decide which Mongo features to implement as commands?

A: Those that seem practical (to me) tend to get implemented. If you find a feature of MongoDB that you think should be implemented as a command, please file an issue. I'm happy to build out commands as they are useful.

Sometimes, though, it makes more sense to perform some MongoDB operations within a command. Manipulating cursors often fall into this category. It makes more sense (in most cases) to treat a cursor as a piece of data inside of a command rather than a command of some sort.

Acknowledgements

This module is built on the node-mongodb-native (aka mongodb) driver library, which provides an excellent evented interface.

This module was sponsored by ConsumerSearch.com, part of the About.Com network, a New York Times company.

pronto-mongodb's People

Contributors

technosophos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.