不要怂,就是干,撸起袖子干!

Commit 407a65bc by Mick Hansen

Merge pull request #4545 from pensierinmusica/patch-2

Update instances.md
2 parents 0cacb9f5 7bf9f467
Showing with 4 additions and 4 deletions
...@@ -84,12 +84,12 @@ task.title = 'a very different title now' ...@@ -84,12 +84,12 @@ task.title = 'a very different title now'
task.save().then(function() {}) task.save().then(function() {})
   
// way 2 // way 2
task.updateAttributes({ task.update({
title: 'a very different title now' title: 'a very different title now'
}).then(function() {}) }).then(function() {})
``` ```
It's also possible to define which attributes should be saved when calling `save`, by passing an array of column names. This is useful when you set attributes based on a previously defined object. E.g. if you get the values of an object via a form of a web app. Furthermore this is used internally for `updateAttributes`. This is how it looks like: It's also possible to define which attributes should be saved when calling `save`, by passing an array of column names. This is useful when you set attributes based on a previously defined object. E.g. if you get the values of an object via a form of a web app. Furthermore this is used internally for `update`. This is how it looks like:
```js ```js
task.title = 'foooo' task.title = 'foooo'
...@@ -98,8 +98,8 @@ task.save({fields: ['title']}).then(function() { ...@@ -98,8 +98,8 @@ task.save({fields: ['title']}).then(function() {
// title will now be 'foooo' but description is the very same as before // title will now be 'foooo' but description is the very same as before
}) })
   
// The equivalent call using updateAttributes looks like this: // The equivalent call using update looks like this:
task.updateAttributes({ title: 'foooo', description: 'baaaaaar'}, {fields: ['title']}).then(function() { task.update({ title: 'foooo', description: 'baaaaaar'}, {fields: ['title']}).then(function() {
// title will now be 'foooo' but description is the very same as before // title will now be 'foooo' but description is the very same as before
}) })
``` ```
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!