OpenKitten / Meow

MongoDB object persistence for Swift
MIT License
66 stars 3 forks source link

Are embeded documents still possible? #14

Closed camdub closed 4 years ago

camdub commented 7 years ago

Some of the documentation I've seen shows an Embeddable protocol that seems not to exist anymore. Is it possible to embed classes or can only Reference be used now?

Joannis commented 7 years ago

Thanks to Swift 4 you don't need to conform to Embeddable anymore, if you embed a struct in your model and it's Codable, that'll work.

Only Reference works for references. You can still nest another model, but that'll make a copy of that model and embed it there. It's possible to re-add this feature, but it would break your models if those referenced models (in-directly) reference yours.

Joannis commented 7 years ago

https://github.com/OpenKitten/Meow/blob/master/1.0/Guides/Models.md