Skip to content

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

Open
@eric-burel

Description

@eric-burel

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

  • Setting at the database level using drivers, but this works only for timestamps.

  • Using a "createSchema" function? The problem is that it means having this extra step for all Vulcan schemas, instead of a nice, raw JSON.

  • Providing a "baseSchema" that we can spread into each schema? Doesn't solve createdAt/updatedAt issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions