My issue here is that if I am trying to create triggers for auditing, I have to specify each column individually or execute a raw SQL query that looks something like this:
INSERT INTO auditing (SELECT * FROM source WHERE source.something = something)
The issue with this is that the auditing table has to look exactly the same as the source table. But that only allows insertion of one entry per element if you want to have the ID as a primary key. I would want to have an "AuditId" and a "SourceId" but that is not possible when using this query!
So I think it would be cool to have a method that you can use similarly to methods like Insert, Update, Upsertand so on called Audit
Would be cool if this could automatically map the columns with the same name and then you would have the ability to attach another method or perhaps a function argument that maps the rest of the values.
My issue here is that if I am trying to create triggers for auditing, I have to specify each column individually or execute a raw SQL query that looks something like this:
INSERT INTO auditing (SELECT * FROM source WHERE source.something = something)
The issue with this is that the auditing table has to look exactly the same as the source table. But that only allows insertion of one entry per element if you want to have the ID as a primary key. I would want to have an "AuditId" and a "SourceId" but that is not possible when using this query!
So I think it would be cool to have a method that you can use similarly to methods like
Insert
,Update
,Upsert
and so on calledAudit
Would be cool if this could automatically map the columns with the same name and then you would have the ability to attach another method or perhaps a function argument that maps the rest of the values.
Usage: