Add support for different idAttribute

This simplifies the logic and also allows you to use a different idAttribute other than 'id'.