본문 바로가기

API5

strapi customizing(2) customizing을 위한 기본적인 내장 함수 설명과, strapi에 의해서 제공되는 기본 APIs 이외 개발자가 생성한 API를 어떻게 추가 하는지 설명 하도록 한다. customizing을 위한 내장 함수 설명 module.exports = { async find(ctx) { let entities; if (ctx.query._q) { entities = await strapi.services['task'].search(ctx.query); } else { entities = await strapi.services['task'].find(ctx.query); } return entities.map(entity => { const item = sanitizeEntity(entity, { model: .. 2020. 12. 18.
strapi relation type 생성과 사용 Relation collection type 앞의 strapi field type설명에서 볼 수 있는 것과 같이 collection에 field를 생성할때 Relation타입으로 생성할 수 있다. 기본적으로 DB의 외래키(foreign key)와 비슷한 역할을 한다. 실제로 DB상에 외래키로 잡히는 것은 아니고 A, B Table사이에 참조 field를 정의 하는 A_B 관계 테이블을 실제로 생성하여 두개의 연결 관계를 strapi에서 중계해준다. To-do subtask Relation 앞의 글에서 task라는 collection을 만들었으니 이어서 subtask라는 collection을 만들고 이를 task에 related field를 하나 만들어 연결해 보도록 하겠다. 먼저 subtask라는 col.. 2020. 12. 4.
strapi Collection 생성과 사용 Collection 기본적으로 collection은 DB의 table이다. 실제로 strapi가 생성하는 collection은 실제 DB에서도 table로 생성된다. PLUGINS/Content-Types Builder를 누른후 나타나는 오른쪽 화면에서 + Create new collection type 을 클릭한다. collection type의 이름을 설정한다. 이 이름은 table name이라고 생각할 수 있다. 다만 Display name은 현재 strapi에서 보여지는 이름이며 고급 설정에 실제로 DB table이름으로 사용될 collection name도 따로 설정은 할 수 있다. Todo List를 만든다는 가정하에, task라는 이름으로 하나의 Collection을 생성한다. 그다음 fie.. 2020. 12. 3.
Sanic BluePrint 사용하기 Sanic Routing기능 Decorator: 명시적으로 @app.route({path},[{method}...]와 같은 방식 @app.route('/',['GET']) : http://xxxx.xxx.xxx path로 request 발생시 이 decorator에 연결된 함수가 호출되어 request를 처리 한다. Blueprint: 아래 예제에서 설명하겟지만 Decorator와 동일한 방식을 사용하지만, 특정 path를 prefix로 먼저 주고, 사용하는 방식이다. REST API의 path는 보통 특정 목적을 가지는 resource group www.sanicbasic.com/api/sanic/Adnl www.sanicbasic.com/api/sanic/B www.sanicbasic.com/api/.. 2020. 10. 29.