al.select.by.name = SELECT * FROM  addrlists WHERE app = ?  AND name = ? AND altype = ?
al.select.by.names = SELECT * FROM  addrlists WHERE app = ?  AND name IN (__nameInPlaceHolder__) AND altype = ?
al.select.by.id = SELECT * FROM addrlists WHERE app = ?  AND id = ? 
al.insert = INSERT INTO addrlists (app, name, mode, altype, istmp, description,subtemplate,bodytemplate,addedby, addedat, addedfromip) VALUES ( ?, ?, ?, ?, ?, ?,?,?,?, ?, ?)
al.update.markunsub.true = UPDATE addr SET al = al::jsonb - ARRAY [__alRecords__],  unsubat = unsubat || ?::jsonb, updatedat = ?, updatedby = ?, updatedfromip = ?
al.update.markunsub.false = UPDATE addr SET al = al::jsonb - ARRAY [ __alRecords__],  updatedat = ?, updatedby = ?, updatedfromip = ?
al.remove.address.unsub.true = UPDATE addr SET al = al::jsonb - ARRAY [ __alRecords__ ],  unsubat = unsubat || ?::jsonb, updatedat = ?, updatedby = ?, updatedfromip = ? WHERE emailaddr IN (__emailPlaceHodlers__)
al.remove.address.unsub.false = UPDATE addr SET al = al::jsonb - ARRAY [__alRecords__],  updatedat = ?, updatedby = ?, updatedfromip = ? WHERE emailaddr IN ( __emailPlaceHodlers__)
al.remove.by.id = DELETE FROM addrlists WHERE app = ? AND id = ?
al.remove.by.name = DELETE FROM addrlists WHERE app = ? AND name = ? AND altype = ?
addr.select.by.al = SELECT emailaddr, uuid, isactive, domain, id FROM addr WHERE al @> ?::jsonb ORDER BY addr
addr.select.by.al.active = SELECT emailaddr, uuid, isactive, domain,profile, id FROM addr WHERE al @> ?::jsonb AND isactive = true ORDER BY addr
addr.select.by.al  = SELECT emailaddr, uuid, isactive, domain, id FROM addr WHERE al @> ?::jsonb ORDER BY addr
al.select.by.idlist = SELECT id, app, altype, name FROM addrlists WHERE app = ? AND id IN (__inPlaceholdes__) ORDER BY id
addr.select.by.email = SELECT  emailaddr, uuid, isactive, domain,profile FROM addr WHERE emailaddr IN ( __inPlaceholdes__ )
addr.insert = INSERT INTO addr(emailaddr, isactive, al, subat, tags, profile, unsubat, domain, uuid, addedat, addedby, addedfromip) values (?, ?, ?::jsonb, ?::jsonb, ?::jsonb, ?::jsonb, ?::jsonb, ?, ?, ?, ?, ?)
addr.update.set.al = UPDATE addr set al = al || ?::jsonb, subat = subat || ?::jsonb, tags = tags || ?::jsonb, updatedat = ?, updatedby = ?,  updatedfromip = ? where emailaddr = ?
addr.update.set.active.true = UPDATE addrlists set isactive = ?, updatedat = ?, updatedby = ?,  updatedfromip = ? where name in ( __namePlaceHolders__ ) and altype = ? and app = ?
addr.update.set.active.false = UPDATE addrlists set isactive = ?, deactivatedby = ?, deactivatedat = ?, deactivatedfromip = ?, updatedat = ?, updatedby = ?,  updatedfromip = ? where name in ( __namePlaceHolders__ ) and altype = ? and app = ?
addr.update.profile= UPDATE addr SET profile = profile || ?::jsonb,updatedat = ?, updatedby = ?,  updatedfromip = ?   where emailaddr = ?
addr.select.tags.by.email = SELECT * FROM addr WHERE emailaddr = ?
al.update.by.name = UPDATE addrlists SET description = ?,subtemplate = ?,bodytemplate = ?, updatedat = ?, updatedby = ?,  updatedfromip = ? where name = ? and altype = ? and app = ?
al.select.by.email.and.names = SELECT al.id, al.app, al.altype, al.name FROM addrlists al JOIN addr a ON a.al @> jsonb_build_array(al.id)::jsonb AND a.emailaddr IN (__emailPlaceHodlers__) WHERE al.app = ? AND al.name IN (__namePlaceHolders__) AND al.altype = ?
addr.select.alids.by.email = SELECT id, al FROM addr WHERE emailaddr IN (__emailPlaceHolders__)
addr.update.alids=UPDATE addr set al = ?::jsonb, subat = subat || ?::jsonb, tags = tags || ?::jsonb, updatedat = ?, updatedby = ?,  updatedfromip = ? where emailaddr = ?
al.select.by.name.from.addr=SELECT al.name FROM (SELECT split_part(jsonb_object_keys(al)::text, '_', 2) AS al_id FROM addr WHERE emailaddr = ?) AS addr_al_ids JOIN addrlists al ON al.id::text = addr_al_ids.al_id;
