{"id":28351412,"url":"https://github.com/phalcon/incubator-mongodb","last_synced_at":"2026-03-03T21:02:56.878Z","repository":{"id":38381654,"uuid":"274901337","full_name":"phalcon/incubator-mongodb","owner":"phalcon","description":"MongoDB Database adapter for Phalcon Framework.","archived":false,"fork":false,"pushed_at":"2024-08-05T14:37:53.000Z","size":201,"stargazers_count":6,"open_issues_count":0,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-12T14:56:28.988Z","etag":null,"topics":["mongodb","mongodb-driver","mongodb-orm"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phalcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-06-25T11:40:11.000Z","updated_at":"2024-11-19T01:13:58.000Z","dependencies_parsed_at":"2024-01-23T21:30:55.772Z","dependency_job_id":"23c13433-9f7e-4cd2-9028-76610d586c8f","html_url":"https://github.com/phalcon/incubator-mongodb","commit_stats":{"total_commits":60,"total_committers":5,"mean_commits":12.0,"dds":"0.23333333333333328","last_synced_commit":"8ac3f5bf40b9283fb8e9b3c61cea5305fa71d18e"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/phalcon/incubator-mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fincubator-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fincubator-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fincubator-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fincubator-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phalcon","download_url":"https://codeload.github.com/phalcon/incubator-mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phalcon%2Fincubator-mongodb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30060680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["mongodb","mongodb-driver","mongodb-orm"],"created_at":"2025-05-27T22:10:46.138Z","updated_at":"2026-03-03T21:02:56.869Z","avatar_url":"https://github.com/phalcon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phalcon\\Incubator\\MongoDB\n\n[![Discord](https://img.shields.io/discord/310910488152375297?label=Discord)](http://phalcon.io/discord)\n[![Packagist Version](https://img.shields.io/packagist/v/phalcon/incubator-mongodb)](https://packagist.org/packages/phalcon/incubator-mongodb)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/phalcon/incubator-mongodb)](https://packagist.org/packages/phalcon/incubator-mongodb)\n[![codecov](https://codecov.io/gh/phalcon/incubator-mongodb/branch/master/graph/badge.svg)](https://codecov.io/gh/phalcon/incubator-mongodb)\n[![Packagist](https://img.shields.io/packagist/dd/phalcon/incubator-mongodb)](https://packagist.org/packages/phalcon/incubator-mongodb/stats)\n\n## Issues tracker\n\nhttps://github.com/phalcon/incubator/issues\n\n## What is it\n\nSet of helpers - simplifying working with mongodb via AR paradigm. \n\n## Helper \n\n`Phalcon\\Incubator\\MongoDB\\Helper`\n\n| Method                               | Description                                            |\n|--------------------------------------|--------------------------------------------------------|\n| `Helper::isValidObjectId($id)`       | Checks if id parameter is a valid ObjectID             |\n| `Helper::convertDatetime($datetime)` | Converts a DateTime object to UTCDateTime from MongoDB |\n\n## Collection Manager\n\nManager controls the initialization of collections, keeping record of relations between the different collections of the application.\n\n```php\nuse Phalcon\\Incubator\\MongoDB\\Mvc\\Collection\\Manager;\n\n$di-\u003eset(\n    'collectionsManager',\n    function () {\n        return new Manager();\n    }\n);\n```\n\n## Collection\n\nActiveRecord class for the management of MongoDB collections.\n\n### Defining collection\n\n```php\nuse Phalcon\\Incubator\\MongoDB\\Mvc\\Collection;\n\nclass RobotsCollection extends Collection\n{\n    public $code;\n\n    public $theName;\n\n    public $theType;\n\n    public $theYear;\n}\n\n$robots = new RobotsCollection($data);\n```\n\n### Search examples\n\n```php\nuse MongoDB\\BSON\\ObjectId;\n\n// How many robots are there?\n$robots = RobotsCollection::find();\n\necho \"There are \", count($robots), \"\\n\";\n\n// How many mechanical robots are there?\n$robots = RobotsCollection::find([\n    [\n        \"type\" =\u003e \"mechanical\",\n    ],\n]);\n\necho \"There are \", count(robots), \"\\n\";\n\n// Get and print virtual robots ordered by name\n$robots = RobotsCollection::findFirst([\n    [\n        \"type\" =\u003e \"virtual\",\n    ],\n    \"order\" =\u003e [\n        \"name\" =\u003e 1,\n    ],\n]);\n\nforeach ($robots as $robot) {\n    echo $robot-\u003ename, \"\\n\";\n}\n\n// Get first 100 virtual robots ordered by name\n$robots = RobotsCollection::find([\n    [\n        \"type\" =\u003e \"virtual\",\n    ],\n    \"order\" =\u003e [\n        \"name\" =\u003e 1,\n    ],\n    \"limit\" =\u003e 100,\n]);\n\nforeach (RobotsCollection as $robot) {\n    echo $robot-\u003ename, \"\\n\";\n}\n\n$robot = RobotsCollection::findFirst([\n    [\n        \"_id\" =\u003e new ObjectId(\"45cbc4a0e4123f6920000002\"),\n    ],\n]);\n\n// Find robot by using \\MongoDB\\BSON\\ObjectId object\n$robot = RobotsCollection::findById(\n    new ObjectId(\"545eb081631d16153a293a66\")\n);\n\n// Find robot by using id as sting\n$robot = RobotsCollection::findById(\"45cbc4a0e4123f6920000002\");\n\n// Validate input\nif ($robot = RobotsCollection::findById($_POST[\"id\"])) {\n    // ...\n}\n```\n\n### Adding behavior\n\n```php\nuse Phalcon\\Incubator\\MongoDB\\Mvc\\Collection;\nuse Phalcon\\Incubator\\MongoDB\\Mvc\\Collection\\Behavior\\Timestampable;\n\nclass RobotsCollection extends Collection\n{\n    public $code;\n\n    public $theName;\n\n    public $theType;\n\n    public $theYear;\n    \n    protected function onConstruct()\n    {\n         $this-\u003eaddBehavior(\n             new Timestampable(\n                 [\n                     \"beforeCreate\" =\u003e [\n                         \"field\"  =\u003e \"created_at\",\n                         \"format\" =\u003e \"Y-m-d\",\n                     ],\n                 ]\n             )\n         );\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalcon%2Fincubator-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphalcon%2Fincubator-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphalcon%2Fincubator-mongodb/lists"}