hans-sequelize-api
Advanced tools
+4
-2
@@ -139,4 +139,5 @@ "use strict"; | ||
| try { | ||
| const { fields, relations, relationFields, relationFilters, relationSort } = req.query; | ||
| const data = req.body; | ||
| const { query, body } = req; | ||
| const { fields, relations, relationFields, relationFilters, relationSort } = query; | ||
| const { data } = body; | ||
| const entity = yield self._postgreModels[modelName].create(data); | ||
@@ -159,2 +160,3 @@ let newEntity; | ||
| else { | ||
| console.log('data: ', data); | ||
| newEntity = yield self._postgreModels[modelName].findOne({ | ||
@@ -161,0 +163,0 @@ where: data, |
+2
-2
| { | ||
| "name": "hans-sequelize-api", | ||
| "version": "1.0.21", | ||
| "version": "1.0.22", | ||
| "description": "rest-api form sequelize-express stack", | ||
@@ -33,5 +33,5 @@ "main": "lib/index.js", | ||
| "dependencies": { | ||
| "hans-http-handlers": "^1.0.5", | ||
| "hans-http-handlers": "^1.0.7", | ||
| "sequelize": "^6.21.3" | ||
| } | ||
| } |
+5
-3
@@ -160,6 +160,7 @@ import {IRouter, Request, Response, Router} from 'express' | ||
| try { | ||
| const {query, body} = req | ||
| const { | ||
| fields, relations, relationFields, | ||
| relationFilters, relationSort | ||
| } = req.query as { | ||
| } = query as { | ||
| fields?: string[], relations: PostgreModelName[] | ||
@@ -170,3 +171,3 @@ relationFields?: Record<PostgreModelName, string[]> | ||
| } | ||
| const data = req.body | ||
| const {data} = body | ||
| const entity = await self._postgreModels[modelName].create(data) | ||
@@ -188,2 +189,3 @@ let newEntity | ||
| } else { | ||
| console.log('data: ', data) | ||
| newEntity = await self._postgreModels[modelName].findOne({ | ||
@@ -201,3 +203,3 @@ where: data, | ||
| } | ||
| status201(res, newEntity!) | ||
| status201(res, newEntity) | ||
| } catch (e: any) { | ||
@@ -204,0 +206,0 @@ error500('api post entity', res, e, __filename) |
51499
0.35%935
0.43%Updated