This project has moved and is read-only. For the latest updates, please go here.

How to get Max() record of particular column in a object store?

Sep 7, 2012 at 11:11 AM

I need to find out maximum record of particular column in a object store. Right now I am using following code to get the maximum value but if you provide the option in linq2IndexedDb.js will be helpful for us.

        var maxArray = [];      

     db.linq.from("ObjectStore").select().then(function (result) {           

console.log("maxArray",maxArray);

var max_of_array = maxArray.length == 0 ? 0 : Math.max.apply(Math, maxArray);            console.log("max_of_array", max_of_array);        },

errorHandler,

function (result) {           

maxArray.push(result.id);       

});

 

result:

     

maxArray[115194,115195,115196,115197,115213,115214,115215,115216,115217,115218,115219,101876,101877,101878,101879,101844,101845,101846,101847,101848,101849,101850,101851,101852,101853,101854,101855,101856,101857,101858,101859,108150,108151,108152,108153,108154,101860,101861,101862,101808,101809,101810,115190,115209,115210,115211,115212,115220,115221,115222,115223,115224,115225,115226,115227,101827,101828,101829,101830,101831,101832,101833,101834,101863,101864,101865,101866,101811,101812,101813,101814,101815,101816,101817,101818,101819,101820,101821,101822,101823,101946,101947,108134,108135,108136,108137,108138,108139,108140,108141,108142,108143,108144,108145,108146,108147,108148,108149,101839,101840,101841,101842,101843,101867,101868,101869,101870,101871,101872,101873,101874,101875,101824,101825,101826,115198,101880,101881,101882,102015,102016,101835,101836,101837,101838,115191]
max_of_array115227

Sep 8, 2012 at 11:02 AM

Hi,

Good idea, I will take a look at it.

greetings,

Kristof