Git Product home page Git Product logo

cfmongodb's Introduction

CFMongoDB

CFMongoDB is both partial wrapper for the MongoDB Java driver and a document-struct mapper for ColdFusion. It attempts to remove the need for constant javacasting in your CFML when working with MongoDB. Additionally, there’s a simple DSL which provides ColdFusion developers the ability to easily search MongoDB document collections.

CFMongoDB works with Adobe ColdFusion 9.0.1+ and Railo 3.2+

Notes

As of August 20, 2011, collection.update(), collection.findAndModify(), and “sort” all introduced breaking changes!

update() and findAndModify()

They no longer wrap documents in {$set} automatically.

You will need to change your “update” documents like so:

old: {newField="hey"}

new: { “$set” = {newField="hey"} }

sort

Sort must now be a structure… string support is no longer supported.

old: find(sort=“TS=-1”)

new: find(sort={"TS"=-1})

Some Code

One of the most appealing aspects is that data can be created as a ColdFusion structure and persisted almost verbatim. Example:

<cfscript>

//save
col = mongo.getDBCollection( 'my_collection' );
my_struct = {
  name = 'Orc #getTickCount()#'
  foo = 'bar'
  bar = 123
  'tags'=[ 'cool', 'distributed', 'fast' ]
};

col.save( my_struct );

//query
result = col.query().startsWith('name','Orc').find(limit=20);
writeOutput("Found #result.size()# of #result.totalCount()# Orcs");

//use the native mongo cursor. it is case sensitive!
cursor = result.asCursor();
while( cursor.hasNext() ){
  thisOrc = cursor.next();
  writeOutput(" name = #thisOrc['name']# <br>");
}

//use a ColdFusion array of structs. this is not case sensitive
orcs = result.asArray();
for(orc in orcs){
  writeOutput(" name = #orc.name# <br>");
}

</cfscript>

More Examples

See examples/gettingstarted.cfm to start.

Additional examples are in the various subdirectories in examples/

The Wiki

Check out the wiki for additional info: http://wiki.github.com/marcesher/cfmongodb/

Getting Help

We have a Google group: http://groups.google.com/group/cfmongodb

Please limit conversations to MongoDB and ColdFusion. General MongoDB questions are best asked on the MongoDB group at http://groups.google.com/group/mongodb-user

Posting Issues

Post issues to the github issue tracker for the project. Better: post fixes. Best: post fixes with unit tests.

Getting Involved

Collaboration is welcome. Fork — Commit — Request a pull. For bug fixes and feature additions, commits with unit tests are much more likely to be accepted.

Code well.

cfmongodb's People

Contributors

aarongreenlee avatar andreacfm avatar ciaranarcher avatar d1rtym0nk3y avatar indy-at-straker avatar indynz avatar marcesher avatar seancorfield avatar zoramite avatar

Watchers

 avatar  avatar  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.