VulcanJS / vulcan-npm

The full-stack JavaScript App Framework
https://vulcan-docs.vercel.app
MIT License
30 stars 8 forks source link

Remove the need for explicit createdAt/updatedAt/userId/_id #95

Open eric-burel opened 2 years ago

eric-burel commented 2 years ago

Is your feature request related to a problem? Please describe.

createdAt and updatedAt are timestamps ; userId is the id of the person that created the document (this is needed to make the "owners" permission group to work) This configuration could belong to the database driver OR use a convention in Vulcan

The problem is that they rely on "onCreate"/"onUpdate" callbacks, that themselves require a server framework.

Describe the solution you'd like createdAt, updatedAt and userId should be edge cases. They should be added automatically to all schemas (eg during model creation?) and handled accordingly in resolvers.

Except if the user explicitely override "onCreate"/"onUpdate" to be null (or a custom function) in a server schema, in which case we should not run the default function, and run the custom function if there is one.

_id schema could also be simplified to "_id: {}" or "_id: true" so that we don't need to make it explicitely optional,

Describe alternatives you've considered