<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -134,6 +134,13 @@ describe(&quot;Finders&quot;, {
   },
   &quot;count&quot;: function() {
     value_of(Person.count()).should_be(5);
+  },
+  &quot;Finding with columns hash for conditions&quot;: function() {
+    value_of(Person.find({conditions:{name: &quot;Nick&quot;}}).id).should_be(1);
+    value_of(Person.find({conditions:{name: &quot;Karen&quot;, age: 30}}).id).should_be(4);
+  },
+  &quot;Finding with arbitrary comparison operators for conditions&quot;: function() {
+    value_of(Person.find({conditions:{age: [&quot;&lt;&quot;, 24]}}).name).should_be(&quot;David&quot;);
   }
 });
 
@@ -195,10 +202,10 @@ describe(&quot;Updating and destroying from Model&quot;, {
     value_of(p.errors).should_include(&quot;age&quot;);
   },
   &quot;Updating all records&quot;: function() {
-    Person.updateAll({name: &quot;Bob&quot;});
+    Person.updateAll({name: &quot;Juan&quot;});
     var people = Person.all();
     JazzRecord.each(people, function(record, index) {
-     value_of(record.name).should_be(&quot;Bob&quot;);
+     value_of(record.name).should_be(&quot;Juan&quot;);
     });
   },
   &quot;Updating all records conditionally&quot;: function() {
@@ -215,7 +222,7 @@ describe(&quot;Updating and destroying from Model&quot;, {
     var people = [1,2,3];
     Person.destroy(people);
     JazzRecord.each(people, function(id, index) {
-      value_of(id).should_be_null();
+      value_of(Person.find(id)).should_be_null();
     });
   },
   &quot;Destroying all records&quot;: function() {
@@ -226,6 +233,6 @@ describe(&quot;Updating and destroying from Model&quot;, {
   &quot;Destroying all records conditionally&quot;: function() {
     value_of(Animal.count()).should_be(5);
     Animal.destroyAll({say: &quot;rawr!&quot;});
-    value_of(Animal.count()).should_be(5);
+    value_of(Animal.count()).should_be(3);
   }
 });
\ No newline at end of file</diff>
      <filename>JSSpec/specs/model.js</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,6 @@
       // JazzRecord.adapter = new JazzRecord.TitaniumAdapter({dbFile: &quot;test.db&quot;});
       // JazzRecord.adapter = new JazzRecord.HTML5Adapter({dbFile: &quot;test.db&quot;});
       JazzRecord.adapter = new JazzRecord.GearsAdapter({dbFile: &quot;test.db&quot;});
-      JazzRecord.debug = true;
       JazzRecord.migrations = migrations;
       JazzRecord.fixtures = fixtures;
       JazzRecord.migrate({refresh:true});</diff>
      <filename>index.html</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
-JazzRecord.Model.prototype.destroy = function(id) {
+// no callbacks, more efficient
+JazzRecord.Model.prototype.deleteRecords = function(id) {
   var conditions = &quot;&quot;;
   if(JazzRecord.getType(id) === 'number')
     conditions = &quot;WHERE id=&quot; + id;
@@ -8,12 +9,36 @@ JazzRecord.Model.prototype.destroy = function(id) {
   this.query();
 };
 
-JazzRecord.Model.prototype.destroyAll = function() {
+// no callbacks, more efficient
+JazzRecord.Model.prototype.deleteAll = function(conditions) {
   this.sql = &quot;DELETE FROM &quot; + this.table;
+  if(conditions)
+    this.sql += &quot; WHERE &quot; + conditions;
   this.query();
 };
 
 JazzRecord.Model.prototype.dropTable = function() {
-     this.sql = &quot;DROP TABLE IF EXISTS &quot; + this.table;
-     this.query();
+  this.sql = &quot;DROP TABLE IF EXISTS &quot; + this.table;
+  this.query();
+};
+
+// callbacks
+JazzRecord.Model.prototype.destroy = function(ids) {
+  var records = this.find(ids);
+  if(JazzRecord.getType(records) === &quot;array&quot;) {
+    JazzRecord.each(records, function(rec, index) {
+      rec.destroy();
+    });
+    return records;
+  }
+  else {
+    records.destroy();
+  }
 };
+
+JazzRecord.Model.prototype.destroyAll = function(conditions) {
+  var records = this.all({conditions: conditions});
+  JazzRecord.each(records, function(rec, index) {
+    rec.destroy();
+  });
+};
\ No newline at end of file</diff>
      <filename>javascripts/model/destroy.js</filename>
    </modified>
    <modified>
      <diff>@@ -11,6 +11,7 @@ JazzRecord.Model.prototype.find = function(options) {
         options = {id: options, limit: 1};
         break;
       case &quot;object&quot;:
+        options.limit = 1;
         break;
       default:
         throw(&quot;Type Error. Model.find() expects Number, Array or Object&quot;);
@@ -63,6 +64,8 @@ JazzRecord.Model.prototype.select = function(options) {
   
   options = JazzRecord.shallowMerge(defaultOptions, options);
   
+  console.log(options);
+  
   if(options.select.indexOf(&quot;id&quot;) === -1 &amp;&amp; options.select.indexOf(&quot;*&quot;) === -1)
     options.select = &quot;id, &quot; + options.select;
   if(options.order || this.options.order) {
@@ -80,9 +83,40 @@ JazzRecord.Model.prototype.select = function(options) {
 
   //add complex conditions handling as in AR
   if(options.conditions) {
-    options.conditions = &quot;WHERE &quot; + options.conditions;
-    if(options.id)
-      options.conditions += &quot; AND id=&quot; + options.id;
+    var conditionSql = &quot;WHERE &quot;;
+    // // simple string
+    if(JazzRecord.getType(options.conditions) === &quot;string&quot;) {
+      options.conditions = conditionSql + options.conditions;
+      if(options.id)
+        options.conditions += &quot; AND id=&quot; + options.id;
+    }
+    else {
+      // obj hash of cols/values
+      JazzRecord.each(this.options.columns, function(colType, colName) {
+        var conditionCol = options.conditions[colName];
+        if(conditionCol) {
+          var conditionType = JazzRecord.getType(conditionCol);
+          switch(conditionType) {
+            // equality
+            case &quot;string&quot;:
+              conditionSql += (colName + &quot;='&quot; + conditionCol.replace(/'/g, &quot;''&quot;) + &quot;' AND &quot;);
+              break;
+            // arbitrary comparison operator, comparison value
+            case &quot;array&quot;:
+              conditionSql += colName + &quot; &quot; + conditionCol[0] + &quot; &quot;;
+              if(JazzRecord.getType(conditionCol[1]) === &quot;string&quot;)
+                conditionSql += (conditionCol[1].replace(/'/g, &quot;''&quot;) + &quot; AND &quot;);
+              else
+                conditionSql += conditionCol[1] + &quot; AND &quot;;
+              break;
+            default:
+              conditionSql += (colName + &quot;=&quot; + conditionCol + &quot; AND &quot;);
+              break;  
+          }
+        }
+      });
+      options.conditions = conditionSql.slice(0, -4);
+    }
   }
   else if(options.id) {
     if(JazzRecord.getType(options.id)=='number') {</diff>
      <filename>javascripts/model/find.js</filename>
    </modified>
    <modified>
      <diff>@@ -74,20 +74,30 @@ JazzRecord.Model.prototype = {
   // update methods enforce validation
   // options is hash of col/values, id is single ID or array
   // returns modified record object whether passed or failed validation if single ID
-  update: function(ids, options) {
-    
+  update: function(ids, updates) {
+    var records = this.find(ids);
+    if(JazzRecord.getType(records) === &quot;array&quot;) {
+      JazzRecord.each(records, function(rec, index) {
+        rec.updateAttributes(updates[index]);
+      });
+      return records;
+    }
+    else {
+      records.updateAttributes(updates);
+      return records;
+    }
   },
   // updates is hash of col/values
   // conditions should be abstracted out
   // does not validate
   updateAll: function(updates, conditions, options) {
-    
-  },
-  // selector is ID or array of IDs
-  destroy: function(ids) {
-    
-  },
-  destroyAll: function(conditions) {
-    
+    if(!JazzRecord.isDefined(options))
+      options = {};
+    if(JazzRecord.isDefined(conditions))
+      options = JazzRecord.shallowMerge(options, {conditions: conditions});
+    var records = this.all(options);
+    JazzRecord.each(records, function(rec, index) {
+      rec.updateAttributes(updates);
+    });
   }
 };</diff>
      <filename>javascripts/model/model.js</filename>
    </modified>
    <modified>
      <diff>@@ -61,7 +61,7 @@ JazzRecord.Record.prototype = {
     if(!this.id)
       throw(&quot;Unsaved record cannot be destroyed&quot;);
     else {
-      this.options.model.destroy(this.id);
+      this.options.model.deleteRecords(this.id);
       // unlink any hasMany and hasOne records from this record
       JazzRecord.each(this.options.model.options.hasMany, function(assocTable, assoc) {
         this.load(assoc);</diff>
      <filename>javascripts/record/record.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b7261e9720e7ca997594c19f48849bcbdb21de47</id>
    </parent>
  </parents>
  <author>
    <name>Nick Carter</name>
    <email>thynctank@thynctank.com</email>
  </author>
  <url>http://github.com/thynctank/jazzrecord/commit/11f8f18f41dfbf303a121a17fa31f35771ef2f33</url>
  <id>11f8f18f41dfbf303a121a17fa31f35771ef2f33</id>
  <committed-date>2009-08-26T02:12:18-07:00</committed-date>
  <authored-date>2009-08-26T02:12:18-07:00</authored-date>
  <message>all tests passing, arbitrary comparison operators in conditions option for finders/conditions hashes</message>
  <tree>ebe622becb40cfedb5372139eb1b502a68474dfc</tree>
  <committer>
    <name>Nick Carter</name>
    <email>thynctank@thynctank.com</email>
  </committer>
</commit>
