본문 바로가기

개발63

[웹 보안] CORS란? 원문: https://dev.to/nicolus/what-you-should-know-about-cors-48d6 CORS는 Cross-Origin Resource Sharing의 줄임말이다. 처음배우는 사람들에게는 CORS가 무엇때문에 사용되는지 헷갈릴때가 많다. 첫째로, CORS는 보안을 강화하기 위한 수단이 아니다. 사실 그의 정반대이다. CORS는 Same Origin Policy(Browser의 정책중 하나로 document나 script가 다른 domain과 교신하는 것을 막는다)를 피하기위함이다. Same Origin Policy는 하나의 도메인에서 다른 도메인으로 요청하는 것을 막는다. 이렇게 하면 악성 웹사이트들이 다른 웹사이트들에게 요청보내는 것을 막을 수 있다. 이 정책은 브라우저에 .. 2019. 12. 25.
[Javascript] 객체에 복수의 프로퍼티가 있는지 확인해주는 함수 Vanilla Javascript: function DoPropertiesExist(parent, propertyNames, operator, isArray){ let checkAND = true let checkOR = false propertyNames.forEach(prop => { //If Property exists console.log(prop) if (Object.prototype.hasOwnProperty.call(parent, prop) && parent[prop] != null) { if (isArray) { if (parent[prop].length == 0) checkAND = false else checkOR = true } else checkOR = true } else { ch.. 2019. 12. 24.
[PostgreSQL 공부하기] PostgreSQL Index는 B-Tree를 어떻게 사용할까? 원문: https://www.qwertee.io/blog/postgresql-b-tree-index-explained-part-1/ 원문: https://en.wikipedia.org/wiki/B-tree Index의 목적은 적은 양의 데이터를 찾을때 disk I/O를 줄이는 것이다. disk를 검색하는 작업은 O(n)이지만 index가 유용하기 위해서는 그보다 더 빨라야한다. PostgreSQL의 default index는 B-Tree로 구성되며 좀 더 정확하게는 B+ Tree로 구성된다. B-Tree와 B+ Tree의 차이점은 key가 저장되는 방식에 있다. B-Tree에서는 각각의 Key들은 leaf node이든 non-leaf node이든 딱 1번만 저장되지만 B+ Tree는 모든 Key들은 le.. 2019. 12. 23.
[PostgreSQL 공부하기] Index는 어떤 column에 생성해야될까? Database page: Database에서 page는 DB가 data를 저장/관리하는 가장 기본적인 단위이다. 쉽게 비유하자면, Database 책 Page Page Row Sentence 하지만 (DB마다 조금씩 다르겠지만), row는 page 용량의 반을 넘어갈 수 없다. https://stackoverflow.com/questions/4401910/mysql-what-is-a-page Clustered Index vs Non-clustered Index: Clustered Index는 index에 저장되는 순서와 같은 순서로 disk에 저장되는 것이다. 따라서 clustered index는 1종류밖에 없다. Non-clustered Index는 실제 물리적으로 저장되는 것과는 별도로 다른 리스트.. 2019. 12. 17.
[PostgreSQL 공부하기] Index의 종류 https://leopard.in.ua/2015/04/13/postgresql-indexes#.XfeTyugzZaR Index는 추가적인 자료구조로서 아래의 목적들의 달성을 위해 도움이 된다: 1. 데이터 검색 2. Optimizer 3. JOIN 4. Relation: except/intersect를 위해 사용될 수 있다. 5. Aggregation: COUNT/MIN/MAX 등의 Aggregatation function들을 효율적으로 계산할 수 있게 해준다. 6. Grouping Index Types: PostgreSQL에는 여러가지 Index타입들이 있으며 각각 다른 사용법을 가지고 있다. B-Tree index: B-Tree는 CREATE INDEX를 하면 default로 생성되는 index이다... 2019. 12. 17.
[ElasticSearch 정리하기] Full Text Search 종류 출처: https://www.elastic.co/guide/en/elasticsearch/reference/current/full-text-queries.html 출처: https://stackoverflow.com/questions/26001002/elasticsearch-difference-between-term-match-phrase-and-query-string 1. term 하나의 term을 찾는다. 이 term은 analyze 되지 않는다. 따라서 대소문자, 복수형 등이 다 구분된다 { "user":"Bennett" } { "query": { "term" : { "user" : "bennett" } } } //아무것도 리턴되지 않는다. (대소문자 구분) 2. match 가장 기본적인 searc.. 2019. 12. 13.