본문 바로가기

Nodejs/Sequelize

(5)
Sequelize migration Manual | Sequelize Migrations Just like you use version control systems such as Git to manage changes in your source code, you can use migrations to keep track of changes to the database. With migrations you can transfer your existing database into another state and vice ver sequelize.org 0. npx 명령어 실행 시 Unable to resolve sequelize package ~.라고 뜬다면 package.json이 있는 경로에서 실행 할 것. 1. 모델 정의 또는 수정 np..
Sequelize Native Query - sequelize.query() 사용법 통계 등 복잡한 쿼리는 시퀄라이즈를 사용하면 더 복잡해져서 native 쿼리를 사용하였다. Model.sequelize.query( query, { type: QueryTypes.SELECT } ); 아래 예제는 연도별 사용자 접속 통계 쿼리이다. Postgresql을 사용중이라면 generate_series를 사용해 날짜/시간을 간단하게 생성할 수 있다. const sequelize = require("sequelize"); const { QueryTypes, Op } = require("sequelize"); const { LogMng } = require('../database/models'); function findAllCompany(params) { let search = {}; if (par..
nodejs sequelize (+postgis) geojson by extent 2021.06.15 - [Nodejs/Sequelize] - Nodejs Sequelize + gdal 을 이용한 shp 업로드 Nodejs Sequelize + gdal 을 이용한 shp 업로드 보통 shp을 업로드할 때 postgresql + postgis 를 사용하고 있는 경우라면 가장 많이 사용하는 업로드 툴은 자체적으로 제공하는 'Postgis 2.0 Shapefile and DBF Loader Exporter' 라는 툴 일 것이다. 이 툴은 DB.. songjang.tistory.com 전 포스팅에서 gdal 을 이용해 shp 파일을 공간테이블에 저장했다. 이제 공간테이블을 조회하여 벡터데이터를 리턴받는WFS (Web Feature Service) 가 제공되어야 할 것이다. WFS 는 보통 O..
Nodejs Sequelize + gdal 을 이용한 shp 업로드 보통 shp을 업로드할 때 postgresql + postgis 를 사용하고 있는 경우라면 가장 많이 사용하는 업로드 툴은 자체적으로 제공하는 'Postgis 2.0 Shapefile and DBF Loader Exporter' 라는 툴 일 것이다. 이 툴은 DBMS에 직접적으로 Connection을 해야하기때문에 실무에서 사용하기 곤란한 상황을 대비하여 SHP 을 업로드하는 다른 방법을 알아보려고 한다. 먼저 관리하고자 하는 샘플 SHP파일을 다운로드 한다. 아래 시도/시군구 경계를 다운로드 한다. 행정경계(시도) 행정경계(시군구) 출처 : http://www.gisdeveloper.co.kr/?p=2332 대한민국 최신 행정구역(SHP) 다운로드 – GIS Developer www.gisdevelop..
Nodejs Express + Sequelize 기본 셋팅(Postgresql) Nodejs 의 ORM Sequelize 초기 셋팅을 위한 라이브러리 설치 // npm $ npm i --save sequelize $ npm i --save pg pg-hstore $ npm i --save js-yaml // yarn $ yarn add sequelize $ yarn add pg pg-hstore $ yarn add js-yaml // sequelize/index.js const { Sequelize, Op, DataTypes } = require('sequelize'); const fs = require('fs'); const path = require('path'); const basename = path.basename(__filename); const yaml = require..