분류 전체보기
-
[Vue3+mongoDB+express ch.4] 라우터 설정 (router)Vue 2020. 12. 31. 17:35
localhost:8080/home으로 접속할 수 있는 라우팅을 설정해보자. npm i vue-router@next router 폴더를 만든 후 index.ts를 추가해준다. //index.ts import { createRouter, createWebHistory, RouteRecordRaw, } from 'vue-router' import Home from '@/components/Home.vue' const routes: RouteRecordRaw[] = [ { path: '/home', name: "home", component: Home }, { path: "/redir", redirect: "/hello" } ] export const router = createRouter({ history:..
-
[Vue3+mongoDB+express ch.3] Frontend Backend 연결Vue 2020. 12. 31. 15:38
이제 frontend에서 요청을 보내면 backend 서버에서 mongoDB에 저장된 정보를 꺼내서 frontend에 보여주는 작업을 해볼것이다. 현재 frontend는 localhost:8080, backend는 localhost:3001에서 돌고있다. 즉 8080에서 요청을 보내면 3001에 가서 작업을 해주고 8080에 응답을 보내줄것이다. backend 프로젝트의 app.ts에 코드를 추가한다. localhost:3001/users라는 path에 접근하면 users를 응답으로 보내준다는 뜻 이다. //app.ts app.get('/users', (req, res) => { User.find().then(users => { console.log(users) res.send({ users }) }) ..
-
vue3 express mongoDB 개발환경 세팅Vue 2020. 12. 29. 18:44
Vue3 설치는 이전 포스팅 참조 Express 로 backend 폴더 설치 npm install -g express-generator express --view=pug backend cd backend npm install npm start 폴더에 app.js 내용 지운 후 다음과같은 코드 작성 또는 backend 폴더 생성 npm init -y npm install express TS 사용하기 src 폴더를 만들고 그 안에 app.ts 생성. 타입스크립트 사용시 모듈을 설치해주어야한다. npm install ts-node npm install -D typescript npm install -D tslint tsc --init 을 통해 tsconfig.json 파일 생성 후 "outDir": "dist..
-
typescript를 사용한 Vue3 프로젝트 환경 만들기Vue 2020. 12. 24. 12:08
npm install --global @vue/cli vue create my-project-name 구조 가장 기본적인 예제부터 보기 위해 HelloWorld.vue 삭제. App.vue 코드를 다음과 같이 변경한다. 안녕하세요. 최상위 components인 App.vue 입니다. 저장 후 8080에 접속 Components 이제 Home이란 component를 만들어보자. components 폴더 안에 Home.vue 파일을 만든 후 코드 작성 //Home.vue 메인 Home 페이지입니다. //App.vue 안녕하세요. 최상위 components인 App.vue 입니다. 이렇게 최상의 App.vue 안에서 Home.vue가 보일 수 있게 만든다. 다시 8080에 접속하면 다음과 같이 App.vu..
-
[동적계획법/Dynamic Programming]LCS 문제(최장 공통 부분 수열) 파이썬 코드알고리즘 2020. 12. 20. 21:28
동적 계획법에 대한 자세한 내용 : 2020/12/13 - [알고리즘] - Dynamic Programming (동적 계획법) what ia LCS? Longest Common Subsequence 는 의 subsequence이다. 는 와 의 common subsequence이다. Longest common subsequence? common subsequence들 중 가장 긴것. 는 와 의 LCS이다. 1. optimal substructure x=, yj=, LCS z에 대해서 마지막 부분에 대응하는 값을 떼고 생각할 수 있다. 이런식으로 작은 문제로 쪼갤 수 있다. 2. recursive x1 x2 ... xi-1 xi y1 y2 y3 ... yj-1 yj case1. xi=yi 이므로 그 이전 문..
-
Typescript로 React 시작하기React 2020. 12. 19. 20:29
새로운 리액트 앱 생성하기 프로젝트를 설치할 곳으로 이동하여 명령어 입력. 뒤에 입력하는 travelog 가 프로젝트 폴더의 이름이 된다. 타입스크립트 설정이 적용된 프로젝트가 생성된다. npx create-react-app travelog --template typescript 정상 설치가 되면 다음과 같은 run commands를 볼 수 있다. cd travelog npm start 해당 프로젝트 폴더로 이동하여 npm start 로 서버를 실행하면 http://localhost:3000 에서 실행된다. 자 이제 본격적으로 코드를 작성 시작! 에 앞서 파일이 너무 많아 안그래도 복잡해 죽겠는데 더 복잡한건 싫으니 필요없는 파일은 다 지워버린다ㅏ 유후! App.tsx index.tsx 빼곤 다 지워도 ..
-
[mysql]외래키 제약조건 변경데이터베이스 2020. 12. 18. 11:15
외래키로 참조당하고있는 데이터를 삭제하면 에러가 발생한다. 10:07:39 DELETE from product where product_code = '002' Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails (`bizcos`.`recipe_mng`, CONSTRAINT `product_code` FOREIGN KEY (`product_code`) REFERENCES `product` (`product_code`)) 0.016 sec 이 문제를 해결하기 위해 참조 당하는 데이터를 삭제하면 참조 하고있는 데이터도 자동으로 같이 삭제해주는 옵션을 추가한다. 이 설정을 위해 우선 테이블의 제약조건이름을 알..
-
P and NP (P NP 문제)알고리즘 2020. 12. 13. 00:57
P문제란? 다항시간 내(reasonable time)에 답을 구할 수 있다. 다루기 쉬운 문제 결정론적 다항시간 문제 NP문제란? Nondeterministic Plynomial time 다항시간 내 풀 수 없는 문제 다항시간내에 풀 수 있는지 없는지 모른다. 다루기 어려운 문제 비결정론적 다항시간 문제 -> 적어도 검산은 쉽게 할 수 있는 문제. 하지만 답을 찾기는 어려운 문제 Unsolvable problems 어떤 알고리즘으로도 풀 수 없는문제 Optimization/Decision problems Hamiltonian paths and cycles Traveling salesman problem Is P=NP? P⊆NP P=NP라면? 복잡하고 어려운 문제들을 다항시간 내에 반드시 풀 수 있다. 하..