agentejo / mongo-lite

Schemaless database on top of SQLite
160 stars 19 forks source link

Document population #4

Closed StevenDevooght closed 10 years ago

StevenDevooght commented 10 years ago

I started working on functionality to populate a document with another sub document. Currently oneToMany and ManyToMany scenario's are supported.

A document can be populated using the following method. The first argument is the property of the document you want to populate. The second argument is the name of the collection used to populate the document.

$collection->find()->populate("categories", "categories")->toArray();

For now only one level of population is supported. Everything is contained within the following commit: https://github.com/StevenDevooght/MongoLite/commit/aefaee61cd4897f3879ef2fdea2ca4bebe8bbbf6

aheinze commented 10 years ago

great! thanks! but I want to keep the MongoLite API as close as possible to the mongodb API, so you can easy switch between them. what do you think about creating a standalone populate helper class which works with both, mongodb and mongolite?

aheinze commented 10 years ago

https://github.com/aheinze/cockpit/tree/master/vendor/MongoHybrid , the population class would perfectly fit there

StevenDevooght commented 10 years ago

Aha, okay. That approach makes more sense indeed. I'll have a look if I can put it in.