Skip to content

Commit

Permalink
Adding support for 'code' and 'binary' types to MongoDB adapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
nateabele committed Jan 29, 2011
1 parent 1e77c21 commit cfd2867
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions libraries/lithium/data/source/MongoDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use MongoDate;
use MongoDBRef;
use MongoRegex;
use MongoBinData;
use MongoGridFSFile;
use lithium\util\Inflector;
use lithium\core\NetworkException;
Expand Down Expand Up @@ -173,7 +174,9 @@ protected function _init() {
'regex' => function($v) { return new MongoRegex($v); },
'integer' => function($v) { return (integer) $v; },
'float' => function($v) { return (float) $v; },
'boolean' => function($v) { return (boolean) $v; }
'boolean' => function($v) { return (boolean) $v; },
'code' => function($v) { return new MongoCode($v); },
'binary' => function($v) { return new MongoBinData($v); },
);
}

Expand Down Expand Up @@ -762,11 +765,13 @@ public function cast($model, array $data, array $options = array()) {
unset($options['schema']);

$typeMap = array(
'MongoId' => 'id',
'MongoDate' => 'date',
'datetime' => 'date',
'timestamp' => 'date',
'int' => 'integer'
'MongoId' => 'id',
'MongoDate' => 'date',
'MongoCode' => 'code',
'MongoBinData' => 'binary',
'datetime' => 'date',
'timestamp' => 'date',
'int' => 'integer'
);

foreach ($data as $key => $value) {
Expand Down

0 comments on commit cfd2867

Please sign in to comment.