fordth / jinqJs

jinqJs provides a simple way to perform SQL like queries on javaScript arrays, collections and web services using LINQ expressions.
Other
93 stars 29 forks source link

isObject returning false on an object #21

Open mcoakley opened 7 years ago

mcoakley commented 7 years ago

I'm building an app with the Loopback and Angular libraries using a Mongo backend. When the client pulls datasets from the Loopback API there are multiple datasets with an "id" field. So I'm using jinqJs to (a) rename the id field so there isn't a collision and then (b) do a join on two datasets. The objects returned from the Loopback API are being retrieved using Loopbacks Angular service which effectively uses Angulars Resource object - so I have arrays of Resource objects.

When I pull the objects into jinqJs and use a .select() to rename the id field the isObject method returns false for the Resource objects so they aren't mapping correctly.

I changed the isObject code to use:

var type = typeof obj; return obj != null && (type == 'object' || type == 'function')

(Which I took from LoDash .isObject())

And now .isObject returns true as expected.

fordth commented 7 years ago

Very cool, thank you. I will take a look and run it through my unit tests about changing the isObject()