“Perbarui instance dalam sekuelisasi” Kode Jawaban

Perbarui instance dalam sekuelisasi

const jane = await User.create({ name: "Jane" });
jane.favoriteColor = "blue"
await jane.update({ name: "Ada" })
// The database now has "Ada" for name, but still has the default "green" for favorite color
await jane.save()
// Now the database has "Ada" for name and "blue" for favorite color
Anies

Perbarui instance dalam sekuelisasi

const jane = await User.create({ name: "Jane" });

jane.set({
  name: "Ada",
  favoriteColor: "blue"
});
// As above, the database still has "Jane" and "green"
await jane.save();
// The database now has "Ada" and "blue" for name and favorite color
Anies

Perbarui instance dalam sekuelisasi

const jane = await User.create({ name: "Jane" });
console.log(jane.name); // "Jane"
jane.name = "Ada";
// the name is still "Jane" in the database
await jane.reload();
console.log(jane.name); // "Jane"
Anies

Jawaban yang mirip dengan “Perbarui instance dalam sekuelisasi”

Pertanyaan yang mirip dengan “Perbarui instance dalam sekuelisasi”

Lebih banyak jawaban terkait untuk “Perbarui instance dalam sekuelisasi” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya