Skip to content
Advertisement

Query updated records in Database

Currently all our tables have a created_at and updated_at timestamp, e.g.

The updated_at field is modified with every INSERT.

This allows us to query all Cart‘s which have been updated since a particular point in time with something like this:

However this would not capture updates to FK relationships such as CartItemss and Users.

Is there a nice way to handle this so that we get all Carts which have either directly or indirectly (via FK relationships) been updated?

Advertisement

Answer

You can use exists:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement