DS.Store#createRecord()

createRecord (modelName, inputProperties) DS.Model

Defined in addon/-private/system/store.js:298

Create a new record in the current store. The properties passed to this method are set on the newly created record.

To create a new instance of a Post:

1
2
3
store.createRecord('post', {
  title: "Rails is omakase"
});

To create a new instance of a Post that has a relationship with a User record:

1
2
3
4
5
var user = this.store.peekRecord('user', 1);
store.createRecord('post', {
  title: "Rails is omakase",
  user: user
});

Parameters:

modelName String
inputProperties Object
a hash of properties to set on the newly created record.

Returns:

DS.Model
record
doc_EmberJs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.