Skip to content
virtix edited this page Sep 13, 2010 · 1 revision

Description of the CFMongoDB DSL

This is in DRAFT form and will probably change

The intent is to make reading and writing data from a MongoDB datastore as simple as possible, hiding the underlying implementation.

A very informal grammar and usage looks like:

<cfscript>
  results = mongo.collection('blog').
                    startsWith('name','foo').  //string
                    endsWith('title','bar').   //string
                    exists('field','value').   //string
       		    regex('field','value').    //string
		    before('field', 'value').  //date
		   after('field', 'value').   //date
                    $eq('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
                    search('title,author,date', limit, start);

    //where search allows the following grammar:
    search(keys=list_of_keys_to_return,sort={field=direction},limit=num,start=num);

</cfscript>
<.pre>
Clone this wiki locally