I created a patch that adds the ability to save an empty object to the collection.
This need arose due to the nature of my system.
The save method in the class Document saves an empty object as an array.
Playback example:
I have Model Car extended Document.
Create $car = new Car();
$car->set('human-id', 1)->save();
$car->update(["human-id" => 1], ['$set' =>["markets-data.1" => ["car" => 1]]]);
Data in DB:
Hello,
I created a patch that adds the ability to save an empty object to the collection. This need arose due to the nature of my system. The save method in the class Document saves an empty object as an array. Playback example: I have Model Car extended Document. Create $car = new Car(); $car->set('human-id', 1)->save(); $car->update(["human-id" => 1], ['$set' =>["markets-data.1" => ["car" => 1]]]); Data in DB:
$car->update(["human-id" => 1], ['$unset' =>["markets-data.1" => ["car" => 1]]]); Data in DB:
$car->save(); Data in DB:
Here is an example of how update works in the native view:
How to use my patch: Create $car = new Car(); $car->set('human-id', 1)->save() Data in DB:
$car->set('markets-data', new \stdClass)->save(); { "_id" : ObjectId(""), "markets-data" : {}, "human-id" : 1 }