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 theget-attribute. Calling it with the option plain = true will only return the values of an instance.

  1. Person.create({
  2. name: 'Rambow',
  3. firstname: 'John'
  4. }).then(john => {
  5. console.log(john.get({
  6. plain: true
  7. }))
  8. })
  9. // result:
  10. // { name: 'Rambow',
  11. // firstname: 'John',
  12. // id: 1,
  13. // createdAt: Tue, 01 May 2012 19:12:16 GMT,
  14. // updatedAt: Tue, 01 May 2012 19:12:16 GMT
  15. // }

Hint:You can also transform an instance into JSON by using JSON.stringify(instance). This will basically return the very same as values.