drift
drift copied to clipboard
Investigate generating CRUD accessors for individual tables
I think that makes sense. I managed to migrate most of our code. But traditionally DAOs are often used for a single entity class. So far we mixed in basic CRUD queries into each DAO for a main entity class. Now there is not much left in the DAO except these CRUD queries and the concern is that, if we move them to drift files, we will have copy & paste errors.
I wonder if Drift can help here with some TBD magic comment/query syntax that leads to Drift generating CRUD queries. I think that could also benefit a lot of people to get the initial jump start when testing or adopting the library.
-- drift:generate-crud(foo)
OR
crud(foo):
leads to
findAllFoo:
SELECT * FROM foo;
findFooById:
SELECT * FROM foo WHERE PK = :PK;
deleteFooById:
DELETE * FROM foo WHERE PK = :PK;
existsFooById:
SELECT EXISTS (SELECT 1 FROM foo WHERE PK = :PK);
....
Originally posted by @kuhnroyal in https://github.com/simolus3/drift/issues/490#issuecomment-1344590398