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

Aggregate Functions (MAX, MIN) to mimic SQL #9

Closed newbie-gk closed 8 years ago

newbie-gk commented 8 years ago

Code below not behaving like it does in SQL; inventory_date_time is created using javascript Date() In SQL Date/Strings are able to do max/min aggregates I do see that orderBy() works, maybe the sorting logic there could be applied in finding max/min with the groupBy() return new jinqJs() .from(springService.localmodelData.inventory) .groupBy('company_sku_code', 'inventory_lot_key', 'inventory_uom') .max('inventory_date_time') .select()

By the way, is there a pattern that can be used to achieve the results I'm looking for?

fordth commented 8 years ago

I created a Plunk example trying to repo your issue: http://plnkr.co/edit/DwTf5E?p=preview It seems to be working as expected, feel free to create a working sample and I will check it out. Thanks.

newbie-gk commented 8 years ago

Thank you for the demo :) . I was using a date string like this: http://plnkr.co/edit/P7TGpD2vYqmIuYfYuuKc?p=preview

I converted my code to date objects like your example and it works fine. Thanks a lot!

fordth commented 8 years ago

No problem, thanks.