{"id":15296382,"url":"https://github.com/eman-development-design/mongodb-helpers","last_synced_at":"2026-02-28T11:10:24.814Z","repository":{"id":55560426,"uuid":"189907537","full_name":"eman-development-design/mongodb-helpers","owner":"eman-development-design","description":"Helper Objects to make writing MongoDB apps easier.","archived":false,"fork":false,"pushed_at":"2024-11-25T22:38:27.000Z","size":107,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-25T23:29:07.515Z","etag":null,"topics":["composer-package","helpers","library","mongodb","php72"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eman-development-design.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-03T00:01:18.000Z","updated_at":"2020-12-22T03:54:07.000Z","dependencies_parsed_at":"2024-04-12T03:44:18.287Z","dependency_job_id":null,"html_url":"https://github.com/eman-development-design/mongodb-helpers","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.2142857142857143,"last_synced_commit":"fd3e0bf1ac23e7b0bda1bb4d0bd6cd2a493c91fe"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eman-development-design%2Fmongodb-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eman-development-design%2Fmongodb-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eman-development-design%2Fmongodb-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eman-development-design%2Fmongodb-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eman-development-design","download_url":"https://codeload.github.com/eman-development-design/mongodb-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227799784,"owners_count":17821715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","helpers","library","mongodb","php72"],"created_at":"2024-09-30T18:10:19.668Z","updated_at":"2026-02-28T11:10:19.787Z","avatar_url":"https://github.com/eman-development-design.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongodb-helpers\nHelper Objects to make writing MongoDB apps easier.\n\n## Helpers\n\n### Sorting Helper\n\nYou can easily add sorting by extending ```DataSorting```\n\n```php\nclass UserSorting extends DataSorting\n{\n    public const Email = 'Email';\n\n    public const FirstName = 'FirstName';\n\n    public const LastName = 'LastName';\n}\n```\n\nyou can then use it like so:\n\n```php\nUserSorting::AddToSortList(UserSorting::FirstName, UserSorting::ASC);\n```\n\nyou then compile the sort list by doing this:\n\n```php\n$sort = UserSorting::GetSortList();\n```\n\nthis wil allow you you add as many sorting rules as you want to a query.\n\n### Model Helper\n\n```MongoModelInterface``` is an interface helper that'll provide some helper methods for handling model data.\n\n```php\nuse MongoDB\\BSON\\Serializable;\nuse MongoDB\\Model\\BSONDocument;\nuse Edd\\MongoDbHelpers\\MongoModelInterface\n\nclass User implements Serializable, MongoModelInterface\n{\n    public $userGuid;\n    public $email;\n    public $firstName;\n    public $lastName;\n    \n    public function bsonSerialize() : array\n    {\n        return [\n            'UserUuid' =\u003e $this-\u003euserUuid,\n            'Email' =\u003e $this-\u003eemail,\n            'FirstName' =\u003e $this-\u003efirstName,\n            'LastName' =\u003e $this-\u003elastName\n        ];\n    }\n\n    public function map(BSONDocument $document)\n    {\n        $this-\u003euserUuid = $document['UserUuid'];\n        $this-\u003eemail = $document['Email'];\n        $this-\u003efirstName = $document['FirstName'];\n        $this-\u003elastName = $document['LastName'];\n    }\n\n    public function toArray() : array\n    {\n        return get_object_vars($this);\n    }\n}\n```\n\n```map``` helps you map a BSON Document result to your model properties.\n\n```toArray``` is for presenting the data as an array.\n\n### Repository Helper\n\n```MongoRepository```  makes it easy to setup a basic repository style architecture, the constructor will create an instance of ```MongoDB\\Client``` .\n\n```SetCollection``` \u0026 ```GetCollection``` setup and provide an instance of ```MongoDB\\Collection```.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feman-development-design%2Fmongodb-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feman-development-design%2Fmongodb-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feman-development-design%2Fmongodb-helpers/lists"}