Skip to content
Browse files

refact-o-rama

  • Loading branch information...
1 parent 90f77f9 commit c6617c4811198433c035af729bc643096eebb9c6 unknown committed Dec 28, 2009
View
2 components/Database.cfc
@@ -11,7 +11,7 @@ set server
config = {
server_name = 'localhost',
server_port = 27017,
- db_name = 'default_db',
+ db_name = 'default_db'
};
mongo = createObject('java', 'com.mongodb.Mongo').init( variables.config.server_name , variables.config.server_port );
View
5 components/MongoDocument.cfc
@@ -72,8 +72,11 @@
<cffunction name="save" returntype="String">
+ <cfset var o_id = '' />
<cfset validate() />
- <cfreturn mongo.put(this.model) />
+ <cfset o_id = mongo.put(this.model) />
+ <cfset this.model['_id'] = o_id.toString() />
+ <cfreturn o_id />
</cffunction>
View
6 test/DocumentFactoryModelTest.cfc
@@ -5,13 +5,15 @@ model = createObject('component','fixture.MyMongoModel');
function new_person(){
person = model.Person( 'bill', '123 main st' );
- person.save();
+ person.save();
+ debug(person);
}
function new_project(){
var members = [ 1,2,3,4,5,6,7 ];
var project = model.Project( 'Cool_101', members );
- project.save();
+ project.save();
+ debug(project);
}
View
8 test/DocumentTest.cfc
@@ -1,4 +1,4 @@
-<cfcomponent extends="mxunit.framework.TestCase">
+<cfcomponent extends="BaseTest">
<cfscript>
mongo = createObject('component','cfmongodb.Mongo').init();
@@ -33,9 +33,9 @@
child = {
name='Jackson',
age=7
- }
+ };
- doc.set('child',child);
+ doc.set('child', child);
id = doc.save();
debug(id);
@@ -50,7 +50,7 @@
doc.set('foo','bar');
id = doc.save();
debug(id.toString());
- doc.delete(id)
+ doc.delete(id);
debug( doc.__props__ );
//deleteById
}
View
2 test/ExpressionBuilderTest.cfc
@@ -1,6 +1,6 @@
<cfcomponent output="false" extends="BaseTest">
<cfscript>
- mongo = createObject('component','cfmongodb.Mongo');
+ mongo = createObject('component','cfmongodb.Mongo').init();
coll = mongo.getCollection('blog');
key_exp = {AUTHOR=1,TITLE=1,TS=1};
keys = createObject('java', 'com.mongodb.BasicDBObject').init(key_exp);
View
8 test/ModelTest.cfc
@@ -4,10 +4,8 @@
--->
<cfscript>
-
function testModel(){
-mongo = createObject('component','cfmongodb.components.MongoDB').init('goodcoders');
-mongo.getDb('goodcoders');
+mongo = createObject('component','cfmongodb.components.MongoDB');
debug(mongo);
developer = mongo.new_doc( 'developers' );
@@ -23,13 +21,11 @@ debug(mongo);
developer1.save();
proj_members = [ developer.get('_id'), developer1.get('_id') ];
-
-
+
project = mongo.new_doc( 'projects' );
project.set('title', 'tops4tots');
project.set('members',proj_members);
project.save();
-
}
</cfscript>

0 comments on commit c6617c4

Please sign in to comment.
Something went wrong with that request. Please try again.