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

74

lib/crud.js

@@ -28,3 +28,3 @@ 'use strict';

};
iface['ubsubscribe' + entity] = (context) => async () => {
iface['unsubscribe' + entity] = (context) => async () => {
const { client } = context;

@@ -38,7 +38,7 @@ channel.delete(client);

iface['create' + entity] = (context) => async (record) => {
const result = await db.pg
const { rows: result } = await db.pg
.insert(entity, record)
.returning(returinings[entity]);
channel.forEach((client) =>
client.emit(`${endpoint}/${entity}`, { status: 'inserted', result }),
client.emit(`${endpoint}/${entity}`, { status: 'created', result }),
);

@@ -50,39 +50,51 @@ return result;

if (methods.includes('get')) {
iface['get' + entity] = (context) => async (conditions) => {
const result = await db.pg.row(entity, ...conditions);
return result;
};
iface['get' + entity] =
(context) =>
async ({ conditions }) => {
const result = await db.pg.row(entity, ...conditions);
return result;
};
}
if (methods.includes('select')) {
iface['select' + entity] = (context) => async (args) => {
const [fields, ...conditions] = args;
const result = await db.pg.select(entity, fields, ...conditions);
return result;
};
iface['select' + entity] =
(context) =>
async ({ fields, conditions }) => {
const result = await db.pg.select(entity, fields, ...conditions);
return result;
};
}
if (methods.includes('update')) {
iface['update' + entity] = (context) => async (args) => {
const [delta, ...conditions] = args;
const result = await db.pg
.update(entity, delta, ...conditions)
.returning(returinings[entity]);
channel.forEach((client) =>
client.emit(`${endpoint}/${entity}`, { status: 'updated', result }),
);
return result;
};
iface['update' + entity] =
(context) =>
async ({ delta, conditions }) => {
const { rows: result } = await db.pg
.update(entity, delta, ...conditions)
.returning(returinings[entity]);
channel.forEach((client) =>
client.emit(`${endpoint}/${entity}`, {
status: 'updated',
result,
}),
);
return result;
};
}
if (methods.includes('delete')) {
iface['delete' + entity] = (context) => async (conditions) => {
const result = await db.pg
.delete(entity, ...conditions)
.returning(returinings[entity]);
channel.forEach((client) =>
client.emit(`${endpoint}/${entity}`, { status: 'deleted', result }),
);
return result;
};
iface['delete' + entity] =
(context) =>
async ({ conditions }) => {
const { rows: result } = await db.pg
.delete(entity, ...conditions)
.returning(returinings[entity]);
channel.forEach((client) =>
client.emit(`${endpoint}/${entity}`, {
status: 'deleted',
result,
}),
);
return result;
};
}

@@ -89,0 +101,0 @@ }

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

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