Laravel-mongodb: created_at not added when records are created using update/upsert

Created on 21 Oct 2016  路  5Comments  路  Source: jenssegers/laravel-mongodb

I think this option should be set by default:
https://docs.mongodb.com/manual/reference/operator/update/setOnInsert/#up._S_setOnInsert

Profile::whereId(1)->update(['name' => 'joe'],['upsert' => true]);

This produces the updated_at but is missing created_at.

Most helpful comment

+1

All 5 comments

+1

Why issue is close?

@quando12 i'm not sure that it's expected behavior

What is the alternative here, use create() if you cannot first find()? upsert (by definition) would create a new document if one could not be found. This (in my opinion) should cause the created_at field to be included automatically.

+1

Was this page helpful?
0 / 5 - 0 ratings