Coddy
Coddy

Reputation: 165

Strongloop related model returns function, not object

I try to make request to mongoDB:



    GeoData.find({
        include: {relation: 'Account'} ,
        where: {
          and: [{
            Coordinate: { 
              near: alarm.Geopoint,
              maxDistance: maxDist.Value,
              unit: 'meters'
            }
          }, {Time: {gt: fromTime}}]
        }
      },function(err, datas){
        _.each(geoDatas, function(val){
          console.log(val); //line 1
          console.log(val.Account); //line 2
        })}

Then query is executed, i receive unexpected result: in line 1 - i can see Account object as the propery of val object in line 2 - i can see that object:


    { [Function: bound ]
      getAsync: [Function: bound ],
      update: [Function: bound ],
      destroy: [Function: bound ],
      create: [Function: bound ],
      build: [Function: bound ],
      _targetClass: 'Account' }

Why i view function except object?

How i can access object ?

Upvotes: 1

Views: 213

Answers (1)

Coddy
Coddy

Reputation: 165

Solved via

let str = JSON.stringify(gData); eval('gData = '+str);

Upvotes: 1

Related Questions