Permalink
Browse files

clean up

  • Loading branch information...
1 parent 340bd98 commit 164043ddc4db44e7e49ebba258cfcea1d0739742 billy committed Oct 18, 2009
Showing with 0 additions and 300 deletions.
  1. +0 −11 Mixin.cfc
  2. +0 −97 Mongo.cfc
  3. +0 −80 MongoMapper.cfc
  4. +0 −10 Person.cfc
  5. +0 −102 SmokeTest.cfc
View
11 Mixin.cfc
@@ -1,11 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-foo = 'bar';
-id = 123;
-
-function bar(){
- return foo;
-}
-</cfscript>
-
-</cfcomponent>
View
97 Mongo.cfc
@@ -1,97 +0,0 @@
-<cfcomponent output="false">
-<!--- Maybe should extend an Abstract Mongo? --->
-
-<cfscript>
-//And this is configurable.
-server_name = 'localhost';
-server_port = 27017;
-db_name = 'default_db';
-collection_name = 'default_collection';
-
-//maybe this goes in super class
-mongo = createObject('java', 'com.mongodb.Mongo').init( variables.server_name , variables.server_port );
-db = mongo.getDb(db_name);
-collection = db.getCollection(collection_name);
-
-
-//------------------------------------------------------------------------//
-function add(key,value,o){
- //add key value pair to object ... todo
-}
-
-function put(o){
- var doc = createObject('java', 'com.mongodb.BasicDBObject').init();
- var id = chr(0);
- doc.putAll(o);
- id = collection.insert(doc).get("_id");
- o._id = id;
- return id;
-}//end function
-
-
-
-function get(field,value){
- var q = createObject('java', 'com.mongodb.BasicDBObject').init(field,value);
- var cursor = collection.find(q);
- return cursor.next();
-} //end function
-
-
-function count(){
- return collection.getCount();
-}
-
-function find(){
-
-} //end function
-
-
-function delete(o){
- var obj = get("_id", o._id);
- return collection.remove(obj); //id's of deleted items
-} //end function
-
-
-
-
-//old
-function __delete(field,value){
- var q = createObject('java', 'com.mongodb.BasicDBObject').init(field,value);
- return collection.remove(q); //id's of deleted items
-} //end function
-
-
-
-//ideally, we would have an object that when called would update itself
-//however, when working with structs, we need to tell MongoDB, which
-//item we want to update, since we are not maintaining the string id
-//in the structure.
-
-//update by object id ..._id
-
-//testing if pass in map what it return
-function findSame(o){
- var new_object = createObject('java', 'com.mongodb.BasicDBObject').init(o);
- return collection.findOne(new_object);
-}
-
-function update(o){
- var obj = get("_id", o._id);
- var new_object = createObject('java', 'com.mongodb.BasicDBObject').init(o);
- return collection.update(obj, new_object, false, false);
-
-} //end function
-
-
-
-//not tested ...
-function switchCollection(collection_name){
- collection = db.getCollection(collection_name);
-}
-
-</cfscript>
-
-<cffunction name="dump">
- <cfdump var="#doc#">
-</cffunction>
-</cfcomponent>
View
80 MongoMapper.cfc
@@ -1,80 +0,0 @@
-
-<!--- Maybe should extend an Abstract Mongo? --->
-
-<cfscript>
-//And this is configurable.
-server_name = 'localhost';
-server_port = 27017;
-db_name = 'default_db';
-collection_name = 'default_collection';
-
-//maybe this goes in super class
-mongo = createObject('java', 'com.mongodb.Mongo').init( variables.server_name , variables.server_port );
-db = mongo.getDb(db_name);
-collection = db.getCollection(collection_name);
-
-
-//------------------------------------------------------------------------//
-
-function put(){
- var doc = createObject('java', 'com.mongodb.BasicDBObject').init();
- doc.putAll( this );
- return collection.insert(doc).get("_id");
-}//end function
-
-
-
-function get(field,value){
- var q = createObject('java', 'com.mongodb.BasicDBObject').init(field,value);
- var cursor = collection.find(q);
- return cursor.next();
-} //end function
-
-
-function count(){
- return collection.getCount();
-}
-
-function _find(){
-
-} //end function
-
-
-
-function delete(field,value){
- var q = createObject('java', 'com.mongodb.BasicDBObject').init(field,value);
- return collection.remove(q); //id's of deleted items
-} //end function
-
-
-
-//ideally, we would have an object that when called would update itself
-//however, when working with structs, we need to tell MongoDB, which
-//item we want to update, since we are not maintaining the string id
-//in the structure.
-
-//update by object id ..._id
-
-//testing if pass in map what it return
-function findSame(o){
- var new_object = createObject('java', 'com.mongodb.BasicDBObject').init(o);
- return collection.findOne(new_object);
-}
-
-function update(_id,o){
- var obj = get("_id", _id);
- var new_object = createObject('java', 'com.mongodb.BasicDBObject').init(o);
- return collection.update(obj, new_object, false, false);
-
-} //end function
-
-
-
-//not tested ...
-function switchCollection(collection_name){
- collection = db.getCollection(collection_name);
-}
-
-</cfscript>
-
-
View
10 Person.cfc
@@ -1,10 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-this.name = 'bill';
-this.email = 'bill@bill.com';
-this.address = {
- street = '123 main',
- city = 'anytown'
-};
-</cfscript>
-</cfcomponent>
View
102 SmokeTest.cfc
@@ -1,102 +0,0 @@
-<cfcomponent output="false" extends="mxunit.framework.TestCase">
-<cfscript>
- mongo = createObject('java', 'com.mongodb.Mongo').init( "localhost" , 27017 );
- //debug(mongo);
- db = mongo.getDB( "mydb" );
- a = [1,2,3,4,5,['x','y','z'],{bar=123.098}];
- a2 = [1,2,3,4];
-
- o = {
- user='bill',
- foo='bar',
- a=a
- };
-
-
- person = {
- name="bill",
- email="billshelton@comcast.net",
- address="123 Main St, Anytown, USA"
- };
-
-
- function listTest() {
- list_doc = createObject('java', 'com.mongodb.BasicDBList').init();
- debug(list_doc);
- fail("can't seem to add to basicdb list");
- id = list_doc.add(1);
- coll = db.getCollection("testCollection");
- coll.insert(list_doc);
-
- }
-
- function serializeTest() {
-
- // debug(a);
- // writeoutput(serializeJSON(a));
- writeoutput(serializeJSON(person));
- jdoc = createObject('java', 'com.mongodb.BasicDBObject').init();
- // debug(jdoc);
- jdoc.putAll(person);
-
-
- //jdoc.putAll(serializeJSON(o));
- //debug(jdoc);
- debug(db.getCollectionNames().toString());
-
- coll = db.getCollection("testCollection");
- q = createObject('java', 'com.mongodb.BasicDBObject').init('NAME','bill');
-
- //debug(coll);
- // coll.remove(q);
- // coll.insert(jdoc);
-
- // theDoc = coll.findOne();
- // debug(theDoc);
-
-
-
- cur = coll.find(q);
- debug(cur.toArray());
- debug( jdoc.keySet().toArray() );
-
- }
-
- function testMongoIsLoaded() {
-
- //debug(db);
- coll = db.getCollection("testCollection");
- debug(coll.toString());
- doc = createObject('java', 'com.mongodb.BasicDBObject').init();
-
- doc.put("name", "MongoDB");
- doc.put("type", "database");
- doc.put("count", 1);
-
- debug(doc);
-
-
- coll.insert(doc);
-
- theDoc = coll.findOne();
- debug(theDoc);
-
-
- //colls = db.getCollectionNames();
- //debug(colls);
-
- }
-
-
-
- function setUp(){
-
- }
-
- function tearDown(){
-
- }
-
-
-</cfscript>
-</cfcomponent>

0 comments on commit 164043d

Please sign in to comment.