我可以不使用 save() 来 createRecord() 吗?
can i createRecord() without using save()?
我正在从头开始学习 ember,但我偶然发现了一些我不太理解的东西:
const newNote = this.store.createRecord('note', {
content: 'once upon a time...',
});
newNote.save().then(this._redirectToNewNote.bind(this));
保存前数据库中createRecord的结果,还是像一个虚拟对象?我可以在不保存的情况下使用 createRecord 吗?
是的。您可以在不保存的情况下使用它,执行 remember 它会在您刷新页面时从商店中删除。
来自ember指南
createRecord is used for creating new records on the client side. This will return a new record in the created.uncommitted state. In order to persist this record to the backend you will need to call record.save().
我正在从头开始学习 ember,但我偶然发现了一些我不太理解的东西:
const newNote = this.store.createRecord('note', {
content: 'once upon a time...',
});
newNote.save().then(this._redirectToNewNote.bind(this));
保存前数据库中createRecord的结果,还是像一个虚拟对象?我可以在不保存的情况下使用 createRecord 吗?
是的。您可以在不保存的情况下使用它,执行 remember 它会在您刷新页面时从商店中删除。
来自ember指南
createRecord is used for creating new records on the client side. This will return a new record in the created.uncommitted state. In order to persist this record to the backend you will need to call record.save().