🚀 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.4.0

39

lib/crud.js

@@ -11,13 +11,16 @@ 'use strict';

for (const name of names) {
const entity = model.entities.get(name);
returinings[name] = Object.keys(entity.fields);
}
for (const [entity, methods] of Object.entries(entities)) {
const channel = channels.get(entity);
const schema = model.entities.get(entity);
const keys = returinings[entity] = Object.keys(schema.fields);
const manys = [];
const ones = [];
keys.forEach((key) => {
const { one, many } = schema.fields[key];
if (one) ones.push({ [key]: one });
if (many) manys.push({ [key]: many });
});
if (methods.includes('schema')) {
iface['schema' + entity] = (context) => async () =>
model.entities.get(entity).toJSON();
iface['schema' + entity] = (context) => async () => schema.toJSON();
}

@@ -58,2 +61,12 @@

const result = await db.pg.row(entity, ...conditions);
if (ones.length > 0) {
for (const one of ones) {
for (const [field, table] of Object.entries(one)) {
const { toLowerCamel } = metarhia.metautil;
const tableIdName = toLowerCamel(table) + 'Id';
const id = result[field + 'Id'];
result[field] = await db.pg.row(table, { [tableIdName]: id });
}
}
}
return result;

@@ -68,2 +81,14 @@ };

const result = await db.pg.select(entity, fields, ...conditions);
for (const row of result) {
if (ones.length > 0) {
for (const one of ones) {
for (const [field, table] of Object.entries(one)) {
const { toLowerCamel } = metarhia.metautil;
const tableIdName = toLowerCamel(table) + 'Id';
const id = row[field + 'Id'];
row[field] = await db.pg.row(table, { [tableIdName]: id });
}
}
}
}
return result;

@@ -70,0 +95,0 @@ };

2

package.json
{
"name": "@oldendev/plugins",
"version": "0.3.0",
"version": "0.4.0",
"description": "CRUD plugin for Metarhia impress, metasql",

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