Permalink
Browse files

old crap

  • Loading branch information...
1 parent 9cda796 commit c6314a0c3f8bc4523954feb7fcab3e0d9a5907aa unknown committed Dec 28, 2009
View
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>cfmongodb</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- </buildSpec>
- <natures>
- <nature>org.cfeclipse.cfml.CFENature</nature>
- </natures>
-</projectDescription>
View
@@ -1,8 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-function init(){
- return this;
-}
-
-</cfscript>
-</cfcomponent>
View
@@ -1,19 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-this.id = '';
-this.title = '';
-this.body = '';
-this.tags = [];
-this.author = '';
-this.pub_date = now();
-this.comments = arrayNew(1);
-
-this.comment = {
-comment_author = 'Coward',
-comment_email = '',
-comment_www = '',
-comment_text = ''};
-
-this.comments[1] = this.comment;
-</cfscript>
-</cfcomponent>
View
@@ -1,33 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-mongo = createObject('component','MongoDB');
-</cfscript>
-
-
-<cffunction name="createBlogPost" access="remote">
- <cfargument name="title" />
- <cfargument name="author" />
- <cfargument name="tags" />
- <cfargument name="text" />
- <cfscript>
- blog = createObject('component','Blog');
- blog.title = arguments.title;
- blog.author = arguments.author;
- blog.tags = listToArray(arguments.tags);
- blog.text = arguments.text;
- mongo.put(blog);
- </cfscript>
-
-</cffunction>
-
-
-<cffunction name="getBlogPosts" access="remote">
- <cfreturn mongo.find() />
-</cffunction>
-
-<cffunction name="deletePost" access="remote">
- <cfargument name="id" type="string" />
- <cfset mongo.deleteById(id) />
-</cffunction>
-
-</cfcomponent>
View
@@ -1,8 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-function init(){
- return this;
-}
-
-</cfscript>
-</cfcomponent>
View
11 DB.cfc
@@ -1,11 +0,0 @@
-<cfcomponent output="false">
-<cfscript>
-this.port = 27017;
-this.server = 'localhost';
-
-function init(){
- return this;
-}
-
-</cfscript>
-</cfcomponent>
View
@@ -1,8 +0,0 @@
-<cfcomponent output="false" extends="Mongo">
-<cfscript>
-function init(){
- return this;
-}
-
-</cfscript>
-</cfcomponent>
View
@@ -1,191 +0,0 @@
-<cfcomponent>
-<cfscript>
-
- /*---------------------------------------------------------------------
-
- DSL for MongoDB searches:
-
- mongo.expressionBuilder().
-
- results = mongo.startsWith('name','foo'). //string
- endsWith('title','bar'). //string
- exists('field','value'). //string
- regex('field','value'). //string
- eq('field','value'). //numeric
- lt('field','value'). //numeric
- gt('field','value'). //numeric
- gte('field','value'). //numeric
- lte('field','value'). //numeric
- in('field','value'). //array
- nin('field','value'). //array
- mod('field','value'). //numeric
- size('field','value'). //numeric
- after('field','value'). //date
- before('field','value'). //date
- search('title,author,date', limit, start);
-
- search(keys=[keys_to_return],limit=num,start=num);
-
-
-
-
--------------------------------------------------------------------------------------*/
-
-builder = createObject('java', 'com.mongodb.BasicDBObjectBuilder').start();
-pattern = createObject('java', 'java.util.regex.Pattern');
-
-function startsWith(element, val){
- var regex = val & '.*';
- builder.add( element, pattern.compile(regex) );
- return this;
-}
-
-function endsWith(element, val){
- var regex = '.*' & val;
- builder.add( element, pattern.compile(regex) );
- return this;
-}
-
-
-function exists(element, val){
- var regex = '.*' & val & '.*';
- builder.add( element, pattern.compile(regex) );
- return this;
-}
-
-
-function regex(element, val){
- var regex = val;
- builder.add( element, pattern.compile(regex) );
- return this;
-}
-
-
-function builder(){
- return builder;
-}
-
-function start(){
- builder.start();
- return this;
-}
-
-function get(){
- return builder.get();
-}
-
-
-//May need at least some exception handling
-function where( js_expression ){
- builder.add( '$where', js_expression );
- return this;
-}
-
-function inArray(element, val){
- builder.add( element, val );
- return this;
-}
-
- //vals should be list or array
-function $in(element,vals){
- if(isArray(vals)) return addArrayCriteria(element,vals,'$in');
- return addArrayCriteria(element, listToArray(vals),'$in');
-}
-
-function $nin(element,vals){
- if(isArray(vals)) return addArrayCriteria(element,vals,'$nin');
- return addArrayCriteria(element, listToArray(vals),'$nin');
-}
-
-
-function $eq(element,val){
- builder.add( element, val );
- return this;
-}
-
-
-function $ne(element,val){
- return addNumericCriteria(element,val,'$ne');
-}
-
-
-function $lt(element,val){
- return addNumericCriteria(element,val,'$lt');
-}
-
-
-function $lte(element,val){
- return addNumericCriteria(element,val,'$lte');
-}
-
-
-function $gt(element,val){
- return addNumericCriteria(element,val,'$gt');
-}
-
-
-function $gte(element,val){
- return addNumericCriteria(element,val,'$gte');
-}
-
-</cfscript>
-
-<cffunction name="before">
- <cfargument name="element" type="string" />
- <cfargument name="val" type="date" />
- <cfscript>
- var exp = {};
- var date = parseDateTime(val);
- exp['$lte'] = date;
- builder.add( element, exp );
- return this;
- </cfscript>
-</cffunction>
-
-
-<cffunction name="after">
- <cfargument name="element" type="string" />
- <cfargument name="val" type="date" />
- <cfscript>
- var exp = {};
- var date = parseDateTime(val);
- exp['$gte'] = date;
- builder.add( element, exp );
- return this;
- </cfscript>
-</cffunction>
-
-<!---
-Note to self: Using cffunction here because of the ability/need to cast
-arbitrary numeric data to java without using JavaCast. CFARGUMENT takes care
-of that. CF9 might too, but most folks are still < CF9.
-
-But, this also proved to be a very good refactor.
- --->
-
-<cffunction name="addNumericCriteria" hint="refactored $expressions for numerics">
- <cfargument name="element" type="string" hint="The element in the document we're searching"/>
- <cfargument name="val" type="numeric" hint="The comparative value of the element" />
- <cfargument name="type" type="string" hint="$gt,$lt,etc. The operators - <><=>= ..." />
- <cfscript>
- var exp = {};
- exp[type] = val;
- builder.add( element, exp );
- return this;
- </cfscript>
-</cffunction>
-
-<cffunction name="addArrayCriteria" hint="refactored $expressions for numerics">
- <cfargument name="element" type="string" hint="The array element in the document we're searching"/>
- <cfargument name="val" type="array" hint="The value(s) of an element in the array" />
- <cfargument name="type" type="string" hint="$in,$nin,etc." />
- <cfscript>
- var exp = {};
- exp[type] = val;
- builder.add( element, exp );
- return this;
- </cfscript>
-</cffunction>
-
-
-</cfcomponent>
Oops, something went wrong.

0 comments on commit c6314a0

Please sign in to comment.