mongodb / laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Home Page:https://www.mongodb.com/compatibility/mongodb-laravel-integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Cast createdAt and updatedAt field by default,that is save by mongoose

masterbater opened this issue · comments

Is your feature request related to a problem?

Not really a problem

Describe the solution you'd like

Cast createdAt and updatedAt field by default, right now it only supports snake_case

Describe alternatives you've considered

I just added this in model to cast it

    const CREATED_AT = 'createdAt';
    const UPDATED_AT = 'updatedAt';

If this feature is supported by Eloquent with SQL databases, this is something we can improve. Otherwise implementing and maintaining this feature for MongoDB would be too complex.

The Date fields seems to inherit timestamp fields by default, using custom names.
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L1483-L1489

If this feature is supported by Eloquent with SQL databases, this is something we can improve. Otherwise implementing and maintaining this feature for MongoDB would be too complex.

The Date fields seems to inherit timestamp fields by default, using custom names. https://github.com/laravel/framework/blob/10.x/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L1483-L1489

Got it. Other hand can you help me with this #2752 I dont see any written documentation other than the source code.