function parseHook(object)
{
    if( object && object.updates )
    {
        object.updates.each(function(row) {

            if( !(row && row.lat != "undefined" && row.lng != "undefined" && row.serial != "undefined"))
            {
                return; // next in .each() parlance
            }
//            var record = {};
//            record.lat = row.lat;
//            record.lon = row.lon;
//            record.serial = row.serial;
//            Devices.insert(record);



            Devices.upsert(
                {
                    // Selector
                    serial: row.serial
                },
                {
                    // Modifier
                    $set: {
                        lat: row.lat,
                        lng: row.lng,
                        serial: row.serial
                    }
                }
            );

//            simpleLog("Update device " + row.serial + " " + JSON.stringify(result));


        });

//        var deviceIds = [];
//        object.updates.each(function(row) {deviceIds.push(row._id)});
//
//        console.log(deviceIds);

        // call process fences in 1 ms
        asyncProcessFences(false);
    }
}
// this parses the hook and calls any processing that needs to occur
this parses the hook and calls any processing that needs to occur
this parses the hook and calls any processing that needs to occur
function parseHook(object)
{
    if( object && object.updates )
    {
        object.updates.each(function(row) {
            if( !(row && row.lat != "undefined" && row.lng != "undefined" && row.serial != "undefined"))
            {
                return; 
            }
            Devices.upsert(
                {
                    serial: row.serial
                },
                {
                    $set: {
                        lat: row.lat,
                        lng: row.lng,
                        serial: row.serial
                    }
                }
            );
        });
        console.log(deviceIds);
         call process fences in 1 ms
        asyncProcessFences(false);
    }
}
function parseHook ( object ) { if ( object && object . updates ) { object . updates . each ( function ( row ) { if ( ! ( row && row . lat != "undefined" && row . lng != "undefined" && row . serial != "undefined" ) ) { return ; } Devices . upsert ( { serial : row . serial } , { $set : { lat : row . lat , lng : row . lng , serial : row . serial } } ) ; } ) ; asyncProcessFences ( false ) ; } }
this parses the hook and calls any processing that needs to occur
this parses the hook and calls any processing that needs to occur
// next in .each() parlance //            var record = {}; //            record.lat = row.lat; //            record.lon = row.lon; //            record.serial = row.serial; //            Devices.insert(record); // Selector // Modifier //            simpleLog("Update device " + row.serial + " " + JSON.stringify(result)); //        var deviceIds = []; //        object.updates.each(function(row) {deviceIds.push(row._id)}); // //        console.log(deviceIds); // call process fences in 1 ms