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

Commit 3f00865f by Ruben Bridgewater

Docs: replace .values with .get({plain: true})

1 parent 81c8b330
...@@ -277,7 +277,9 @@ sequelize.Promise.all([ ...@@ -277,7 +277,9 @@ sequelize.Promise.all([
// Get the association // Get the association
return source.getTarget(); return source.getTarget();
}).then(function(_target) { }).then(function(_target) {
console.log(_target.values) console.log(_target.get({
plain: true
}))
/* /*
{ {
id: 1, id: 1,
......
...@@ -68,7 +68,9 @@ It is also possible to define which attributes can be set via the create method& ...@@ -68,7 +68,9 @@ It is also possible to define which attributes can be set via the create method&
```js ```js
User.create({ username: 'barfooz', isAdmin: true }, [ 'username' ]).then(function(user) { User.create({ username: 'barfooz', isAdmin: true }, [ 'username' ]).then(function(user) {
// let's assume the default of isAdmin is false: // let's assume the default of isAdmin is false:
console.log(user.values) // => { username: 'barfooz', isAdmin: false } console.log(user.get({
plain: true
})) // => { username: 'barfooz', isAdmin: false }
}) })
``` ```
...@@ -241,14 +243,16 @@ Tasks.bulkCreate([ ...@@ -241,14 +243,16 @@ Tasks.bulkCreate([
## Values of an instance ## Values of an instance
If you log an instance you will notice, that there is a lot of additional stuff. In order to hide such stuff and reduce it to the very interesting information, you can use the`values`-attribute. Calling it will return only the values of an instance. If you log an instance you will notice, that there is a lot of additional stuff. In order to hide such stuff and reduce it to the very interesting information, you can use the`get`-attribute. Calling it with the option `plain` = true will only return the values of an instance.
```js ```js
Person.create({ Person.create({
name: 'Rambow', name: 'Rambow',
firstname: 'John' firstname: 'John'
}).then(function(john) { }).then(function(john) {
console.log(john.values) console.log(john.get({
plain: true
}))
}) })
   
// result: // result:
......
...@@ -579,7 +579,9 @@ Let's assume we have an empty database with a `User` model which has a `username ...@@ -579,7 +579,9 @@ Let's assume we have an empty database with a `User` model which has a `username
User User
.findOrCreate({where: {username: 'sdepold'}, defaults: {job: 'Technical Lead JavaScript'}}) .findOrCreate({where: {username: 'sdepold'}, defaults: {job: 'Technical Lead JavaScript'}})
.spread(function(user, created) { .spread(function(user, created) {
console.log(user.values) console.log(user.get({
plain: true
}))
console.log(created) console.log(created)
/* /*
...@@ -603,7 +605,9 @@ User ...@@ -603,7 +605,9 @@ User
User User
.findOrCreate({where: {username: 'fnord'}, defaults: {job: 'something else'}}) .findOrCreate({where: {username: 'fnord'}, defaults: {job: 'something else'}})
.spread(function(user, created) { .spread(function(user, created) {
console.log(user.values) console.log(user.get({
plain: true
}))
console.log(created) console.log(created)
/* /*
......
...@@ -26,6 +26,8 @@ return sequelize.sync().then(function() { ...@@ -26,6 +26,8 @@ return sequelize.sync().then(function() {
birthday: new Date(1980, 06, 20) birthday: new Date(1980, 06, 20)
}); });
}).then(function(jane) { }).then(function(jane) {
console.log(jane.values) console.log(jane.get({
plain: true
}))
}); });
``` ```
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!