Advice on which Lucid commit to use

When looking at tutorials I have seen two different ways to commit to a database.

  1. const user = User.create(data)

  2. const user - new User() set values on the object and then use user.save.

Both these commit to the DB so what would influence the choice of which to use?

Thanks

1 Like

Hello!

It won’t matter much, basically whatever “feels” better for your use-case

User.create(data) might be better when you already have data

new User() and setting values might be better, when values come from other functions or conditionals etc

It’s just code style mostly

2 Likes

Great, thank you - that has helped