MasoniteFramework / orm

Masonite ORM is a beautiful Python ORM. It's also a nearly drop in replacement of the Orator ORM
https://orm.masoniteproject.com
MIT License
160 stars 47 forks source link

Automatically remember the user who created or updated #850

Closed tpow closed 9 months ago

tpow commented 1 year ago

It would be handy to have a quick way to include created_by and updated_by properties in the model that automatically store the user id of the user making the change. This would be similar to the timestamps mixin (which provides the created_at and updated_at properties) and would be set and updated similarly - created_by stored when initially creating the object and updated_by stored when touched or changed.

When using the SoftDeletes mixin (which adds the deleted_at property), it might also be nice to include the deleted_by property.

I started looking at doing this. I am trying to figure out how to identify the "current user" generically to the ORM. Perhaps this mixin would be better placed in Masonite? I think this could be valuable to anyone using the ORM, though.

josephmancuso commented 9 months ago

This should be done as a mixin but i dont think it should be in the core project.