MongoRecord icon indicating copy to clipboard operation
MongoRecord copied to clipboard

Adding fields definition/validation support

Open macedd opened this issue 10 years ago • 0 comments

Most of the problems I've found with Mongo was with data types. Its possible to overcome it by strictly casting your data (not one of php strengths..), but this is error prone and lazy developer will bring problems.

So I have implemented this optional fields definition where is it possible to define data types to your fields.

Usage

class Transport extends BaseMongoRecord
{
    protected static $collectionName = 'transport';
    protected static $fields = array(
        'name' => 'str',
        'price' => 'int',
        'manufacturer' => 'str',
        'weels' => 'int',
        );
}

macedd avatar Apr 24 '14 19:04 macedd