Reputation: 366
I am trying to access email and password field but i dont know where this '0'
came. I am retrieving object from rethinkdb and it looks good without '0'
. But then am using Lodash _.assign()
method like this
var user = new User
var finduser ={}
dbuser = finduser // dbuser is the object retrieving from db
user = _.assign(user,finduser)
I am getting data like this
{
'0': {
'email': '[email protected]',
'pswd': 'kdkd'
}
}
I just want to access email field
Upvotes: 0
Views: 4979
Reputation: 4526
you are retrieving array of data from database. That's how the 0
is coming. There should be a .first()
method on db
query or ORM
you are using which will return single object of user
not array.
Upvotes: 0
Reputation: 17910
You can access like this,
user['0'].email
or
user['0']['email']
Upvotes: 1