src/db/Table.js
function idSequencer(_currMax, userPassedId) {
    let currMax = _currMax;
    let newMax;
    let newId;

    if (currMax === undefined) {
        currMax = -1;
    }

    if (userPassedId === undefined) {
        newMax = currMax + 1;
        newId = newMax;
    } else {
        newMax = Math.max(currMax + 1, userPassedId);
        newId = userPassedId;
    }

    return [
        newMax, // new max id
        newId, // id to use for row creation
    ];
}
function idSequencer(_currMax, userPassedId) {
    let currMax = _currMax;
    let newMax;
    let newId;

    if (currMax === undefined) {
        currMax = -1;
    }

    if (userPassedId === undefined) {
        newMax = currMax + 1;
        newId = newMax;
    } else {
        newMax = Math.max(currMax + 1, userPassedId);
        newId = userPassedId;
    }

    return [
        newMax, // new max id
        newId, // id to use for row creation
    ];
}
function idSequencer ( _currMax , userPassedId ) { let currMax = _currMax ; let newMax ; let newId ; if ( currMax === undefined ) { currMax = - 1 ; } if ( userPassedId === undefined ) { newMax = currMax + 1 ; newId = newMax ; } else { newMax = Math . max ( currMax + 1 , userPassedId ) ; newId = userPassedId ; } return [ newMax , // new max id newId , // id to use for row creation ] ; }
Input is the current max id and the new id passed to the create action. Both may be undefined. The current max id in the case that this is the first Model being created, and the new id if the id was not explicitly passed to the database.  Return value is the new max id and the id to use to create the new row. If the id's are strings, the id must be passed explicitly every time. In this case, the current max id will remain `NaN` due to `Math.max`, but that's fine.
Input is the current max id and the new id passed to the create action . Both may be undefined . The current max id in the case that this is the first Model being created and the new id if the id was not explicitly passed to the database . Return value is the new max id and the id to use to create the new row . If the id s are strings the id must be passed explicitly every time . In this case the current max id will remain NaN due to Math . max but that s fine .