Permalink
Browse files

synch

  • Loading branch information...
bill shelton
bill shelton committed May 31, 2010
2 parents 0132d69 + 972e635 commit 1b27387d67895d253fd33bacdfadd08c64e96ec9
Showing with 15,832 additions and 147 deletions.
  1. +4 −0 README.textile
  2. +1 −1 components/ExpressionBuilder.cfc
  3. +2 −1 components/MongoConfig.cfc
  4. +29 −19 components/MongoDB.cfc
  5. +9 −10 components/MongoDocument.cfc
  6. +20 −5 doc/api/allclasses-frame.html
  7. +71 −5 doc/api/cfmongodb/Mongo.html
  8. +39 −4 doc/api/cfmongodb/components/-.html
  9. +1,535 −0 doc/api/cfmongodb/components/.tmp_MongoDB.html.71003~
  10. +76 −7 doc/api/cfmongodb/components/Collection.html
  11. +76 −5 doc/api/cfmongodb/components/Database.html
  12. +159 −23 doc/api/cfmongodb/components/Document.html
  13. +210 −9 doc/api/cfmongodb/components/ExpressionBuilder.html
  14. +243 −0 doc/api/cfmongodb/components/MongoConfig.html
  15. +163 −1 doc/api/cfmongodb/components/MongoDB.html
  16. +690 −0 doc/api/cfmongodb/components/MongoDocument.html
  17. +7 −7 doc/api/cfmongodb/components/package-frame.html
  18. +51 −18 doc/api/cfmongodb/components/package-summary.html
  19. +32 −1 doc/api/cfmongodb/doc/ColdDoc.html
  20. +1 −1 doc/api/cfmongodb/doc/package-frame.html
  21. +1 −1 doc/api/cfmongodb/doc/package-summary.html
  22. +1 −1 doc/api/cfmongodb/javaloader/JavaLoader.html
  23. +3 −3 doc/api/cfmongodb/javaloader/JavaProxy.html
  24. +1 −1 doc/api/cfmongodb/javaloader/package-frame.html
  25. +1 −1 doc/api/cfmongodb/javaloader/package-summary.html
  26. +4 −1 doc/api/cfmongodb/package-frame.html
  27. +28 −2 doc/api/cfmongodb/package-summary.html
  28. +31 −1 doc/api/cfmongodb/test/BaseTest.html
  29. +823 −0 doc/api/cfmongodb/test/CollectionEachIteratorTest.html
  30. +1 −1 doc/api/cfmongodb/test/DatabaseTest.html
  31. +854 −0 doc/api/cfmongodb/test/DocumentFactoryModelTest.html
  32. +99 −7 doc/api/cfmongodb/test/DocumentTest.html
  33. +1,542 −0 doc/api/cfmongodb/test/ExpressionBuilderTest.html
  34. +823 −0 doc/api/cfmongodb/test/InheritedDocumentTest.html
  35. +854 −0 doc/api/cfmongodb/test/IntrospectionTest.html
  36. +823 −0 doc/api/cfmongodb/test/ModelTest.html
  37. +823 −0 doc/api/cfmongodb/test/MongoConfigTest.html
  38. +1 −1 doc/api/cfmongodb/test/MongoDBTest.html
  39. +823 −0 doc/api/cfmongodb/test/MongoDocumentTest.html
  40. +1 −1 doc/api/cfmongodb/test/MongoSmokeTest.html
  41. +793 −0 doc/api/cfmongodb/test/NewDocumentTest.html
  42. +854 −0 doc/api/cfmongodb/test/ObjectMappingTest.html
  43. +1 −1 doc/api/cfmongodb/test/SearchMongoTest.html
  44. +793 −0 doc/api/cfmongodb/test/TestSuiteTest.html
  45. +357 −0 doc/api/cfmongodb/test/fixture/MyMongoDocument.html
  46. +345 −0 doc/api/cfmongodb/test/fixture/MyMongoModel.html
  47. +424 −0 doc/api/cfmongodb/test/fixture/PersonModel.html
  48. +424 −0 doc/api/cfmongodb/test/fixture/SomeCFCWithProperties.html
  49. +334 −0 doc/api/cfmongodb/test/fixture/TestCFC.html
  50. +51 −0 doc/api/cfmongodb/test/fixture/package-frame.html
  51. +207 −0 doc/api/cfmongodb/test/fixture/package-summary.html
  52. +34 −1 doc/api/cfmongodb/test/package-frame.html
  53. +111 −1 doc/api/cfmongodb/test/package-summary.html
  54. +5 −2 doc/api/index.html
  55. +6 −1 doc/api/overview-frame.html
  56. +22 −1 doc/api/overview-summary.html
  57. +9 −0 test/MongoConfigTest.cfc
  58. +17 −0 test/MongoDocumentTest.cfc
  59. +70 −0 test/ObjectMappingTest.cfc
  60. +18 −0 test/fixture/PersonModel.cfc
  61. +2 −2 test/fixture/SomeCFCWithProperties.cfc
View
@@ -22,5 +22,9 @@ Collaboration is welcome.
+h2. CFMongoDB - An Object Mapper for MongoDB and ColdFusion
+This is the current development branch (0.9) and should be rolled into master at some point.
+
+Please contact me with any questions or if you're want to collaborate. virtix at gmail
@@ -1,4 +1,4 @@
-<cfcomponent>
+<cfcomponent hint="Creates a Domain Specific Language (DSL) for querying MongoDB collections.">
<cfscript>
/*---------------------------------------------------------------------
@@ -1,6 +1,7 @@
<cfcomponent output="false" hint="Main configuration information for MongoDb connections. Defaults are provided, but should be changed as needed. ">
<cfscript>
-
+ //To Do: Add various deployment environments: dev,test,stagging, production...
+
//Default values
this.defaults = {
server_name = 'localhost',
View
@@ -1,28 +1,23 @@
<cfcomponent output="false" hint="Facade for Mongo DB. 90% of calls will go through this comonent.">
<cfscript>
-//This maybe should be a config object
-config = {
- server_name = 'localhost',
- server_port = 27017,
- db_name = 'default_db',
- collection_name = 'default_collection'
- };
+config = createObject('component','MongoConfig');
//maybe this goes in super class? Or make factory for returning mongos
/*--------------------------------------------------------------------
mongo1 = factory.createMongo(config);
--------------------------------------------------------------------*/
-mongo = createObject('java', 'com.mongodb.Mongo').init( variables.config.server_name , variables.config.server_port );
-db = mongo.getDb(config.db_name);
-collection = db.getCollection(config.collection_name);
+mongo = createObject('java', 'com.mongodb.Mongo').init( config.defaults.server_name , config.defaults.server_port );
+db = mongo.getDb(config.defaults.db_name);
+collection = db.getCollection(config.defaults.collection_name);
expression_builder = createObject('component', 'ExpressionBuilder') ;
+//Starting to smell ...
function init(config){
- variables.config = arguments.config;
- mongo = createObject('java', 'com.mongodb.Mongo').init( variables.config.server_name , variables.config.server_port );
+ config.defaults = arguments.config;
+ mongo = createObject('java', 'com.mongodb.Mongo').init( config.defaults.server_name , config.defaults.server_port );
db = mongo.getDb(config.db_name);
collection = db.getCollection(config.collection_name);
return this;
@@ -63,11 +58,20 @@ function config(){
builder = createObject('component','ExpressionBuilder');
+ // TO DO: loose the reference to duplicate(this)!!!
+ // This has a bad smell ...
function new_doc(collection_name){
- var document = createObject('component','MongoDocument').factory_init( collection_name, this );
+ var document = createObject('component','MongoDocument').factory_init( collection_name, duplicate(this) );
return document;
}
-
+
+//Returns a document object based on the model
+function build_doc(model){
+ var document = createObject('component','MongoDocument');
+ document.model = model;
+ return document;
+}
+
function getMongo(){
return mongo;
@@ -101,8 +105,11 @@ function get(field,value){
//when only a string id is available
function getById(id){
- var objId = createObject('java','com.mongodb.ObjectId').init(id);
- return get("_id", objId);
+ var str_id = id;
+ var objId = chr(0);
+ if(isObject(id)) str_id = id.toString();
+ obj_id = createObject('java','com.mongodb.ObjectId').init(str_id);
+ return get("_id", obj_id);
} //en
@@ -131,7 +138,6 @@ function delete(o){
//Note the ObjectId object. This creates an ObjectId from
//the string representation of
-
function deleteById(id){
var objId = createObject('java','com.mongodb.ObjectId').init(id);
var obj = get("_id", objId);
@@ -140,7 +146,7 @@ function deleteById(id){
function update(o){
- var obj = get("_id", o._id);
+ var obj = getById( o._id);
var new_object = createObject('java', 'com.mongodb.BasicDBObject').init(o);
return collection.update(obj, new_object, false, false);
@@ -151,7 +157,6 @@ function update(o){
//swtich to or create database
function getDB(db_name){
variables.db = mongo.getDb(db_name);
- this.db = mongo.getDb(db_name);
db = mongo.getDb(db_name);
return db;
}
@@ -180,6 +185,11 @@ function listToStruct(list){
}
+
+function dbRef(collection_name, id){
+ return createObject('java','com.mongodb.DBRef').init( db, collection_name, id);
+}
+
/*---------------------------------------------------------
Expression Builder Wrappers
---------------------------------------------------------*/
@@ -30,7 +30,7 @@
</cffunction>
-<cffunction name="factory_init" hint="Constructor. Creates an instance of a MongoDocument using the specified mongo.">
+<cffunction name="factory_init" access="package" hint="Constructor. Creates an instance of a MongoDocument using the specified mongo.">
<cfargument name="collection_name" type="string" required="true" hint="The name of the collection to which this document is bound." />
<cfargument name="_mongo" type="any" required="false" default="#variables.mongo#" hint="The instance of the Mongo wrapper to which the document is bound." />
<cfset variables.mongo = _mongo />
@@ -75,26 +75,25 @@
<cfset var o_id = '' />
<cfset validate() />
<cfset o_id = mongo.put(this.model) />
- <cfset this.model['_id'] = o_id.toString() />
+ <cfset this.model['_id'] = o_id />
<cfreturn o_id />
</cffunction>
<cffunction name="delete" returntype="void" hint="Deletes this Document from the Collection">
- <cfset mongo.deleteById(this.model['_id']) />
+ <cfset mongo.delete(this.model) />
</cffunction>
+<!--- To Do: Update in-place using obj.update(property,value) --->
<cffunction name="update" hint="Performs in-place update of the the value for 'property'. NOT IMPLEMENTED">
- <cfargument name="property">
- <cfargument name="value">
- <cfset validate() />
- <cfthrow type="NotImplementedException" message="To Do.">
+ <cfargument name="property" required="false" />
+ <cfargument name="value" required="false" />
+ <cfset validate() />
+ <cfset variables.mongo.update(this.model) />
</cffunction>
-<cffunction name="validate" hint="Should be called before save() to perform any required validation. NOT IMPLEMENTED" returntype="void">
-
-</cffunction>
+<cffunction name="validate" hint="Should be called before save() to perform any required validation. NOT IMPLEMENTED" returntype="void"></cffunction>
</cfcomponent>
@@ -1,9 +1,10 @@
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by colddoc on {ts '2009-12-28 15:45:07'} -->
+<!-- Generated by colddoc on {ts '2009-12-31 07:10:55'} -->
<TITLE>
All Classes
</TITLE>
@@ -22,6 +23,9 @@
<TR>
<TD NOWRAP><FONT CLASS="FrameItemFont">
+<A HREF="cfmongodb/components/-.html" title="class in cfmongodb.components" target="classFrame">-</A>
+<BR>
+
<A HREF="cfmongodb/test/BaseTest.html" title="class in cfmongodb.test" target="classFrame">BaseTest</A>
<BR>
@@ -40,9 +44,6 @@
<A HREF="cfmongodb/test/DatabaseTest.html" title="class in cfmongodb.test" target="classFrame">DatabaseTest</A>
<BR>
-<A HREF="cfmongodb/components/Document.html" title="class in cfmongodb.components" target="classFrame">Document</A>
-<BR>
-
<A HREF="cfmongodb/test/DocumentFactoryModelTest.html" title="class in cfmongodb.test" target="classFrame">DocumentFactoryModelTest</A>
<BR>
@@ -55,7 +56,7 @@
<A HREF="cfmongodb/test/ExpressionBuilderTest.html" title="class in cfmongodb.test" target="classFrame">ExpressionBuilderTest</A>
<BR>
-<A HREF="cfmongodb/components/IDocument.html" title="class in cfmongodb.components" target="classFrame">IDocument</A>
+<A HREF="cfmongodb/test/InheritedDocumentTest.html" title="class in cfmongodb.test" target="classFrame">InheritedDocumentTest</A>
<BR>
<A HREF="cfmongodb/test/IntrospectionTest.html" title="class in cfmongodb.test" target="classFrame">IntrospectionTest</A>
@@ -76,6 +77,9 @@
<A HREF="cfmongodb/components/MongoConfig.html" title="class in cfmongodb.components" target="classFrame">MongoConfig</A>
<BR>
+<A HREF="cfmongodb/test/MongoConfigTest.html" title="class in cfmongodb.test" target="classFrame">MongoConfigTest</A>
+<BR>
+
<A HREF="cfmongodb/components/MongoDB.html" title="class in cfmongodb.components" target="classFrame">MongoDB</A>
<BR>
@@ -85,6 +89,9 @@
<A HREF="cfmongodb/components/MongoDocument.html" title="class in cfmongodb.components" target="classFrame">MongoDocument</A>
<BR>
+<A HREF="cfmongodb/test/MongoDocumentTest.html" title="class in cfmongodb.test" target="classFrame">MongoDocumentTest</A>
+<BR>
+
<A HREF="cfmongodb/test/MongoSmokeTest.html" title="class in cfmongodb.test" target="classFrame">MongoSmokeTest</A>
<BR>
@@ -97,6 +104,12 @@
<A HREF="cfmongodb/test/NewDocumentTest.html" title="class in cfmongodb.test" target="classFrame">NewDocumentTest</A>
<BR>
+<A HREF="cfmongodb/test/ObjectMappingTest.html" title="class in cfmongodb.test" target="classFrame">ObjectMappingTest</A>
+<BR>
+
+<A HREF="cfmongodb/test/fixture/PersonModel.html" title="class in cfmongodb.test.fixture" target="classFrame">PersonModel</A>
+<BR>
+
<A HREF="cfmongodb/test/SearchMongoTest.html" title="class in cfmongodb.test" target="classFrame">SearchMongoTest</A>
<BR>
@@ -116,3 +129,5 @@
</BODY>
</HTML>
+
+
Oops, something went wrong.

0 comments on commit 1b27387

Please sign in to comment.