3

In the docs, they don't really explain the difference between what should go in options and what should go in attributes. Is it just model-specific data (like columns in your db) in attrbutes and other stuff in options?

bdwain
  • 1,665
  • 16
  • 35

1 Answers1

3

The attributes you pass are the fields of your model and yes these fields usually are the same in your DB or backend .

and the options are just parameters that will help you manage your model, like the collection that It belogns to, perhaps this specific model needs a diferent url, or the data that you are sending in the attributes needs to be parsed first.

But the options are not mandatory or required, are just there for you whenever you need them, but its fine if you just pass the attributes

from the documentation

If you pass a {collection: ...} as the options, the model gains a collection property that will be used to indicate which collection the model belongs to, and is used to help compute the model's url. The model.collection property is otherwise added automatically when you first add a model to a collection.

{url: "..."} and/or {urlRoot: "..."} options may be passed when creating a new model that needs to have a custom one-off URL endpoint.

If {parse: true} is passed as an option, the attributes will first be converted by parse before being set on the model.

Rayweb_on
  • 3,727
  • 20
  • 24