laravel-mongodb
laravel-mongodb copied to clipboard
Timestamps not hydrated on embedded models
<?php
class Model extends \Jenssegers\Mongodb\Model
{
public function association()
{
return $this->embedsMany('ModelChild');
}
}
class ModelChild extends \Jenssegers\Mongodb\Model
{
}
$model = new Model;
$child = new ChildModel;
$model->association()->associate($child);
$model->save(); // The child's timestamps ARE NOT hydrated
$model = new Model;
$child = new ChildModel;
$model->save();
$model->association()->save($child); // The child's timestamps ARE hydrated
The result should have been the same regardless the way we saved the model (preferably, the timestamps should be there is both cases).
Can confirm, had the same problem. The save() saves the timestamps while associate() does not.
The issue is still relevant using v3.4.6.
@jenssegers, any comments? Maybe something was analyzed and some conclusions were made before closing this issue back in 2018? 🙂
The issue is still relevant using v3.4.6.
@jenssegers, any comments? Maybe something was analyzed and some conclusions were made before closing this issue back in 2018? 🙂
@lllypa you can create issue with description and demonstration problem. We are open for community
@Smolevich, sure. I was thinking of understanding the reason for closing this one first, before opening the same one again. Or re-opening this one, as the description would be a duplicate - I am still having the exact issue @Rezouce described in this issue.
Embed model is old functional that can consist many bugs
Embed model is old functional that can consist many bugs
@Smolevich, is there any new/alternative "best practice" for embedded documents then? I mean, "embedded documents" is an inseparable part of MongoDB. How else one could describe it in Eloquent?
I am also wondering, if this isn't best practise, it should be removed from the docs.