🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@oldendev/plugins

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oldendev/plugins - npm Package Compare versions

Comparing version

to
0.5.0

29

lib/crud.js

@@ -9,15 +9,25 @@ 'use strict';

const { model } = application.schemas;
const returinings = {};
const returnings = {};
for (const [entity, methods] of Object.entries(entities)) {
const { toLowerCamel } = metarhia.metautil;
const returning = returnings[entity] = [];
const channel = channels.get(entity);
const schema = model.entities.get(entity);
const keys = returinings[entity] = Object.keys(schema.fields);
const keys = Object.keys(schema.fields);
const manys = [];
const ones = [];
keys.forEach((key) => {
for (const key of keys) {
const { one, many } = schema.fields[key];
if (one) ones.push({ [key]: one });
if (many) manys.push({ [key]: many });
});
if (one) {
ones.push({ [key]: one });
returning.push(key + 'Id');
continue;
}
if (many) {
manys.push({ [key]: many });
continue;
}
returning.push(key);
}

@@ -48,3 +58,3 @@ if (methods.includes('schema')) {

.insert(entity, record)
.returning(returinings[entity]);
.returning(returnings[entity]);
channel.forEach((client) =>

@@ -65,3 +75,2 @@ client.emit(`${endpoint}/${entity}`, { status: 'created', result }),

for (const [field, table] of Object.entries(one)) {
const { toLowerCamel } = metarhia.metautil;
const tableIdName = toLowerCamel(table) + 'Id';

@@ -104,3 +113,3 @@ const id = result[field + 'Id'];

.update(entity, delta, ...conditions)
.returning(returinings[entity]);
.returning(returnings[entity]);
channel.forEach((client) =>

@@ -122,3 +131,3 @@ client.emit(`${endpoint}/${entity}`, {

.delete(entity, ...conditions)
.returning(returinings[entity]);
.returning(returnings[entity]);
channel.forEach((client) =>

@@ -125,0 +134,0 @@ client.emit(`${endpoint}/${entity}`, {

{
"name": "@oldendev/plugins",
"version": "0.4.0",
"version": "0.5.0",
"description": "CRUD plugin for Metarhia impress, metasql",

@@ -5,0 +5,0 @@ "main": "plugins.js",