Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eric-burel opened this issue Dec 28, 2021 · 0 comments
Open

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

eric-burel opened this issue Dec 28, 2021 · 0 comments
Labels
easy / good first issue Good for newcomers enhancement New feature or request

Comments

@eric-burel
Copy link
Collaborator

eric-burel commented Dec 28, 2021

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

@eric-burel eric-burel added enhancement New feature or request easy / good first issue Good for newcomers labels Dec 28, 2021
@eric-burel eric-burel changed the title Remove the need for explicit createdAt/updatedAt/userId Remove the need for explicit createdAt/updatedAt/userId/_id Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy / good first issue Good for newcomers enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant