Skip to content

Commit

Permalink
describe Single Collection Inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
sokil committed Jan 13, 2015
1 parent b958806 commit 86e328b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 1.12.2@DEV
## 1.12.2(2015-01-13)
* `Operator` refactoring and bugfixes
* Fix Collection::update when update data set as array

## 1.12.1 (2015-01-10)
* Set `Structure` to document as embedded document
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ echo $col1->getOption('regexp')[1]; // 42

### Document schema and validating

#### Custom document class

Custom document class may be useful when required some processing of date on load, getting or save. Custom document class must extend `\Sokil\Mongo\Document`.

```php
Expand All @@ -393,6 +395,13 @@ class CustomCollection extends \Sokil\Mongo\Collection
}
```

#### Single Collection Inheritance

Often useful to have different document classes, which store data in single collection.
For example you have products in your shop `Song` and `VideoClip`, which inherit abstract `Product`.
They have same fields like author or duration, but may also have other different fields and
behaviors. This situation described in example [Product Catalog](http://docs.mongodb.org/ecosystem/use-cases/product-catalog/).

You may flexibly configure document's class in `\Sokil\Mongo\Collection::getDocumentClassName()` relatively to concrete document's data:

```php
Expand Down

0 comments on commit 86e328b

Please sign in to comment.