Skip to content

Commit

Permalink
Merge pull request #18 from myyrakle/fix/#17
Browse files Browse the repository at this point in the history
[#17] 케이스 변환 문제
  • Loading branch information
myyrakle authored Oct 24, 2023
2 parents 1292b5a + 419264f commit 535ae5c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eojuk

![](https://img.shields.io/badge/language-Typescript-yellow) ![](https://img.shields.io/badge/version-0.10.4-brightgreen) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)]()
![](https://img.shields.io/badge/language-Typescript-yellow) ![](https://img.shields.io/badge/version-0.10.5-brightgreen) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)]()

어죽은 테이블 작성 쿼리를 ORM 코드들로 변환해주는 유용한 도구입니다.
기존 RAW Query를 마이그레이션하거나 ERD 도구에서 추출해낸 쿼리를 기반으로 엔티티 코드를 작성하기 좋습니다.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eojuk",
"version": "0.10.4",
"version": "0.10.5",
"description": "",
"keywords": [
"mysql",
Expand Down
17 changes: 12 additions & 5 deletions src/output/mongery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import Table from "../types/table";
import { convertNameCaseByOption } from "../util.ts/name";
import { TAB } from "../util.ts/tab";

// 첫번째 문자만 대문자로 변경
function convertToPascal(original: string) {
return original.charAt(0).toUpperCase() + original.slice(1);
}

// 첫번째 문자만 소문자로 변경
function convertToCamel(original: string) {
return original.charAt(0).toLowerCase() + original.slice(1);
}

export class MongeryEmitter implements IEmmiter {
private option: IOption;

Expand All @@ -26,17 +36,14 @@ export class MongeryEmitter implements IEmmiter {

column.dbType = this.replaceType(column.dbType);

let fieldName = convertNameCaseByOption("PASCAL", column.name);
let fieldName = convertToPascal(column.name);

if (column.name === "_id") {
fieldName = "ID";
isPrimaryKey = true;
}

const bsonName =
column.name == "_id"
? "_id"
: convertNameCaseByOption("CAMEL", column.name);
const bsonName = convertToCamel(column.name);

// PrimaryKey 강제 추가 옵션
if (column.name == this.option.autoAddPrimaryKey) {
Expand Down
25 changes: 25 additions & 0 deletions test/pg/test_for_go2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE "payment_method" (
"_id" ObjectID NOT NULL,
"shopID" ObjectID NOT NULL,
"cardName" string NULL,
"cardAlias" string NULL,
"isDefault" bool NULL,
"customer_uid" string NULL,
"merchant_uid" string NULL,
"email" string NULL,
"cardNumber" string NULL,
"expirePeriod" string NULL,
"cardCompany" string NULL,
"createDate" Time NULL,
"deleteDate" Time NULL
);

COMMENT ON COLUMN "payment_method"."cardAlias" IS '결제수단 별명';

COMMENT ON COLUMN "payment_method"."cardNumber" IS '마스킹';

COMMENT ON COLUMN "payment_method"."expirePeriod" IS '마스킹';

ALTER TABLE "payment_method" ADD CONSTRAINT "PK_PAYMENT_METHOD" PRIMARY KEY (
"_id"
);

0 comments on commit 535ae5c

Please sign in to comment.