如何使用模型在商店中创建新记录
How to create a new record in a dstore using dmodel
我将模型分配给一家商店,然后致电
var model = Store.create({id:0,firstName:"john",lastName:"smith",department:"sales"});
model.save();
这会发送一个 PUT 请求。它不应该发送 POST 吗?我尝试不包括 id 字段,但它会引发验证错误。知道我做错了什么吗?
您似乎无法发送任何 ID 并获得它 POST。那么最好的方法是
var model = Store.create({firstName: "john", lastName: "smith", department: "sales"});
Store.add(model);
或
var model = new MyModel({firstName: "john", lastName: "smith", department: "sales"});
Store.add(model);
我将模型分配给一家商店,然后致电
var model = Store.create({id:0,firstName:"john",lastName:"smith",department:"sales"});
model.save();
这会发送一个 PUT 请求。它不应该发送 POST 吗?我尝试不包括 id 字段,但它会引发验证错误。知道我做错了什么吗?
您似乎无法发送任何 ID 并获得它 POST。那么最好的方法是
var model = Store.create({firstName: "john", lastName: "smith", department: "sales"});
Store.add(model);
或
var model = new MyModel({firstName: "john", lastName: "smith", department: "sales"});
Store.add(model);