1
I have several years of experience with Laravel and am taking a look at the Adonisjs framework. It is very similar to the Laravel in several points, but specifically I’m having a doubt regarding the filling of data of a model Lucid.
For example, in Laravel I usually use the method fill
to fill only some desired fields through a array
, to save
that information.
I tried to use the fill
in Adonisjs in a similar way, but an error was appearing, as if the other fields had been deleted. When I used the merge
, I didn’t have that problem, the behavior was similar to that of the fill
of Laravel.
For example:
const usuario = await Usuario.find(1)
usuario.merge({"nome": "Wallace"});
usuario.save(); // Aqui é ok
usuario.fill({"nome" : "Wallace"});
usuario.save(); // Aqui dá erro
On that note, I ask:
- What are the differences between
fill
andmerge
in Adonisjs? - When using one or the other?
You don’t need to delete your answers and post a new one. Just edit.
– Sam