PHPackages                             astraller/yii2-mongodb-embedded - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. astraller/yii2-mongodb-embedded

ActiveYii2-extension[Database &amp; ORM](/categories/database)

astraller/yii2-mongodb-embedded
===============================

Yii2 extension to work with embedded documents in MongoDB.

1.1.0(7y ago)02MITPHP

Since Sep 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Astraller/yii2-mongodb-embedded)[ Packagist](https://packagist.org/packages/astraller/yii2-mongodb-embedded)[ RSS](/packages/astraller-yii2-mongodb-embedded/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

yii2-mongodb-embedded
=====================

[](#yii2-mongodb-embedded)

Yii2 extension to work with embedded documents in MongoDB.

This extension requires MongoDB PHP Extension version 1.0.0 or higher.
This extension requires MongoDB server version 3.0 or higher.

Installation
------------

[](#installation)

The preferred way to install this extension is through composer.
Either run

```
php composer.phar require --prefer-dist astraller/yii2-mongodb-embedded

```

or add

```
"astraller/yii2-mongodb-embedded": "^1.*"

```

to the require section of your composer.json.

Usage
-----

[](#usage)

- Your model must be inherited from astraller\\mongodb\\MongoModel class.
- Add embedAttributes method

```
    public function embedAttributes() {
        return [
            'conditions' => [
                'class' => DialogConditions::class,
                'type'  => 'many',
            ],
            'text'       => [
                'class' => Text::class,
                'type'  => 'one',
            ],
            'variants' => [
                'class' => Dialog::class,
                'type' => 'manyById'
            ]
        ];
    }
```

- Your embedded documents must be inherited from EmbeddedDocument class.

```
