Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

hans-sequelize-api

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hans-sequelize-api - npm Package Compare versions

Comparing version
1.0.24
to
1.0.25
+10
-8
lib/index.js

@@ -158,5 +158,6 @@ "use strict";

else {
const where = Object.assign(Object.assign({}, body), { _userId: undefined, _role: undefined });
delete body._userId;
delete body._role;
newEntity = yield self._postgreModels[modelName].findOne({
where,
where: body,
attributes: fields || defaultFields,

@@ -184,5 +185,5 @@ include: self._getRelationsInclude({

try {
const { fields, relations, relationFields, relationFilters, relationSort } = req.query;
const { id } = req.params;
const data = req.body;
const { query, body, params } = req;
const { fields, relations, relationFields, relationFilters, relationSort } = query;
const { id } = params;
//@ts-ignore

@@ -192,3 +193,3 @@ const entity = yield self._postgreModels[modelName].findOne({ where: { id } });

return (0, hans_http_handlers_1.error404)(res);
const updatedEntity = yield (entity === null || entity === void 0 ? void 0 : entity.update(data));
const updatedEntity = yield (entity === null || entity === void 0 ? void 0 : entity.update(body));
let newEntity;

@@ -209,4 +210,6 @@ if (updatedEntity.getDataValue('id')) {

else {
delete body._userId;
delete body._role;
newEntity = yield self._postgreModels[modelName].findOne({
where: data,
where: body,
attributes: fields || defaultFields,

@@ -220,3 +223,2 @@ include: self._getRelationsInclude({

});
console.log(newEntity);
}

@@ -223,0 +225,0 @@ (0, hans_http_handlers_1.status200)(res, newEntity);

{
"name": "hans-sequelize-api",
"version": "1.0.24",
"version": "1.0.25",
"description": "rest-api form sequelize-express stack",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -186,5 +186,6 @@ import {IRouter, Request, Response, Router} from 'express'

} else {
const where = {...body, _userId: undefined, _role: undefined}
delete body._userId
delete body._role
newEntity = await self._postgreModels[modelName].findOne({
where,
where: body,
attributes: fields || defaultFields,

@@ -210,6 +211,7 @@ include: self._getRelationsInclude({

try {
const {query, body, params} = req
const {
fields, relations, relationFields,
relationFilters, relationSort
} = req.query as {
} = query as {
fields?: string[], relations: PostgreModelName[]

@@ -220,8 +222,7 @@ relationFields?: Record<PostgreModelName, string[]>

}
const {id} = req.params
const data = req.body
const {id} = params
//@ts-ignore
const entity = await self._postgreModels[modelName].findOne({where: {id}})
if (!entity) return error404(res)
const updatedEntity = await entity?.update(data)
const updatedEntity = await entity?.update(body)
let newEntity

@@ -241,4 +242,6 @@ if (updatedEntity.getDataValue('id')) {

} else {
delete body._userId
delete body._role
newEntity = await self._postgreModels[modelName].findOne({
where: data,
where: body,
attributes: fields || defaultFields,

@@ -252,3 +255,2 @@ include: self._getRelationsInclude({

})
console.log(newEntity)
}

@@ -255,0 +257,0 @@ status200(res, newEntity)