Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MongoRecord
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Lu Wang
  • MongoRecord
  • Merge requests
  • !10

Adding fields definition/validation support

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Thiago F Macedo requested to merge github/fork/macedd/master into master Apr 24, 2014
  • Overview 0
  • Commits 4
  • Pipelines 0
  • Changes 1

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',
        );
}
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/macedd/master