ericsnguyen/micromongo
Composer 安装命令:
composer require ericsnguyen/micromongo
包简介
description
README 文档
README
small object document mapper.
Usage
At your endpoint
list($mongo, $database) = ApplicationDbContext::initialDbConnection(); // binding it to DI container to reuse SimpleDi::bindingInstance(Database::class,$database); SimpleDi::bindingInstance(Client::class, $mongo);
Define Entity
class ARandomEntity extends BaseEntity { /** * if you want to igrnore this field, * just put @\MicroOdm\Annotations\UnPersist() to it * @UnPersist * @var array */ private array $domainEvents = []; protected ?int $iid; // for multi domain protected ?string $dmn; protected ?string $school; protected ?User $u; // for the nest object, must define full namespace // we will upgrade in next version /** * @return \Uni\Domains\Share\ObjectValues\User|null */ public function getU(): ?User { return $this->u; } /** * @param \Uni\Domains\Share\ObjectValues\User|null $u */ public function setU(?User $u): void { $this->u = $u; } }
Get the Repository to interact with Db
// at repository class CreditRepository extends BaseEntityRepository { public function __construct(Database $database) { // the entity class $entityClass = Credit::class; parent::__construct($entityClass, $database); } }
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-19