Skip to content

Commit

Permalink
feat(dao): prefix dao obj with "dao", rather than suffix, for better …
Browse files Browse the repository at this point in the history
…autocomplete
  • Loading branch information
uladkasach committed Jun 7, 2024
1 parent 65d8494 commit 4a026f2
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 133 deletions.
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@
"build:clean": "rm dist/ -rf",
"build:compile": "tsc -p ./tsconfig.build.json",
"build": "npm run build:clean && npm run build:compile",
"provision:docker:up": "docker-compose -f ./provision/docker/integration_test_db/docker-compose.yml up -d --force-recreate --build --renew-anon-volumes",
"provision:docker:await": "docker-compose -f ./provision/docker/integration_test_db/docker-compose.yml exec -T postgres /root/wait-for-postgres.sh",
"provision:docker:down": "docker-compose -f ./provision/docker/integration_test_db/docker-compose.yml down",
"provision:integration-test-db": "npm run provision:docker:up && npm run provision:docker:await && npm run provision:docker:extensions",
"provision:docker:clear": "docker rm -f $(docker ps -a -f 'publish=7821' -q) 2>/dev/null || true && echo 'ensured port is available 👍'",
"provision:docker:prepare": "echo 'no preparation required for this repo'",
"provision:docker:up": "docker-compose -f ./provision/docker/integration-test-db/docker-compose.yml up -d --force-recreate --build --renew-anon-volumes",
"provision:docker:await": "docker-compose -f ./provision/docker/integration-test-db/docker-compose.yml exec -T postgres /root/wait-for-postgres.sh",
"provision:docker:down": "docker-compose -f ./provision/docker/integration-test-db/docker-compose.yml down",
"provision:schema:plan": "echo 'sql schema control not needed for this repo'",
"provision:schema:apply": "echo 'sql schema control not needed for this repo'",
"provision:schema:sync": "echo 'sql schema control not needed for this repo'",
"provision:integration-test-db": "npm run provision:docker:clear && npm run provision:docker:prepare && npm run provision:docker:up && npm run provision:docker:await && npm run provision:schema:plan && npm run provision:schema:apply && npm run provision:schema:plan",
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
"test:types": "tsc -p ./tsconfig.build.json --noEmit",
"test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
build:
context: .
dockerfile: build-image.dockerfile
container_name: superimportantdb_server
container_name: sqldaogeneratordb_server
command: postgres -c 'max_connections=500'
ports:
- 7821:5432
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { findByUnique } from './findByUnique';
import { findByUuid } from './findByUuid';
import { upsert } from './upsert';
export const geocodeDao = {
export const daoGeocode = {
findById,
findByUnique,
findByUuid,
upsert,
};",
"relpath": "geocodeDao/index.ts",
"relpath": "daoGeocode/index.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand All @@ -31,7 +31,7 @@ export const castFromDatabaseObject = (
latitude: dbObject.latitude,
longitude: dbObject.longitude,
}) as HasMetadata<Geocode>;",
"relpath": "geocodeDao/castFromDatabaseObject.ts",
"relpath": "daoGeocode/castFromDatabaseObject.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -72,7 +72,7 @@ export const findById = async ({
if (!dbObject) return null;
return castFromDatabaseObject(dbObject);
};",
"relpath": "geocodeDao/findById.ts",
"relpath": "daoGeocode/findById.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -118,7 +118,7 @@ export const findByUnique = async ({
if (!dbObject) return null;
return castFromDatabaseObject(dbObject);
};",
"relpath": "geocodeDao/findByUnique.ts",
"relpath": "daoGeocode/findByUnique.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -159,7 +159,7 @@ export const findByUuid = async ({
if (!dbObject) return null;
return castFromDatabaseObject(dbObject);
};",
"relpath": "geocodeDao/findByUuid.ts",
"relpath": "daoGeocode/findByUuid.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -197,7 +197,7 @@ export const upsert = async ({
const { id, uuid } = results[0]!; // grab the db generated values
return new Geocode({ ...geocode, id, uuid }) as HasMetadata<Geocode>;
};",
"relpath": "geocodeDao/upsert.ts",
"relpath": "daoGeocode/upsert.ts",
},
]
`;
Expand All @@ -209,12 +209,12 @@ exports[`defineDaoCodeFilesForDomainObject should not have the findByUuid file i
import { findByUnique } from './findByUnique';
import { upsert } from './upsert';
export const geocodeDao = {
export const daoGeocode = {
findById,
findByUnique,
upsert,
};",
"relpath": "geocodeDao/index.ts",
"relpath": "daoGeocode/index.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand All @@ -230,7 +230,7 @@ export const castFromDatabaseObject = (
latitude: dbObject.latitude,
longitude: dbObject.longitude,
}) as HasMetadata<Geocode>;",
"relpath": "geocodeDao/castFromDatabaseObject.ts",
"relpath": "daoGeocode/castFromDatabaseObject.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -270,7 +270,7 @@ export const findById = async ({
if (!dbObject) return null;
return castFromDatabaseObject(dbObject);
};",
"relpath": "geocodeDao/findById.ts",
"relpath": "daoGeocode/findById.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -315,7 +315,7 @@ export const findByUnique = async ({
if (!dbObject) return null;
return castFromDatabaseObject(dbObject);
};",
"relpath": "geocodeDao/findByUnique.ts",
"relpath": "daoGeocode/findByUnique.ts",
},
GeneratedCodeFile {
"content": "import { HasMetadata } from 'type-fns';
Expand Down Expand Up @@ -353,7 +353,7 @@ export const upsert = async ({
const { id } = results[0]!; // grab the db generated values
return new Geocode({ ...geocode, id }) as HasMetadata<Geocode>;
};",
"relpath": "geocodeDao/upsert.ts",
"relpath": "daoGeocode/upsert.ts",
},
]
`;
Loading

0 comments on commit 4a026f2

Please sign in to comment.