@opengis/fastify-table 1.1.22 → 1.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # fastify-table
2
2
 
3
- ## 1.1.22 - 03.10.2024
3
+ ## 1.1.23 - 03.10.2024
4
4
 
5
5
  - add user API and unit tests
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "main": "index.js",
@@ -41,10 +41,10 @@ COMMENT ON COLUMN admin.user_properties.property_key IS 'Ключ';
41
41
  ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS property_json json;
42
42
  COMMENT ON COLUMN admin.user_properties.property_json IS 'Значення налаштування';
43
43
 
44
- ALTER TABLE admin.properties ADD COLUMN IF NOT EXISTS property_entity text;
45
- COMMENT ON COLUMN admin.properties.property_entity IS 'Сутність';
46
- ALTER TABLE admin.properties ADD COLUMN IF NOT EXISTS property_title text;
47
- COMMENT ON COLUMN admin.properties.property_title IS 'Назва';
44
+ ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS property_entity text;
45
+ COMMENT ON COLUMN admin.user_properties.property_entity IS 'Сутність';
46
+ ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS property_title text;
47
+ COMMENT ON COLUMN admin.user_properties.property_title IS 'Назва';
48
48
 
49
49
  ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS uid text NOT NULL DEFAULT '1'::text;
50
50
  ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS editor_id text;
@@ -53,6 +53,6 @@ ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS cdate timestamp witho
53
53
  ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS files json;
54
54
 
55
55
  ALTER TABLE admin.user_properties ADD CONSTRAINT admin_user_properties_property_id_pkey PRIMARY KEY(property_id);
56
- alter table admin.user_properties add constraint user_properties_key_uid_unique UNIQUE (property_key,uid);
56
+ ALTER TABLE admin.user_properties ADD CONSTRAINT user_properties_key_uid_unique UNIQUE (property_key,property_entity,uid);
57
57
 
58
58
  COMMENT ON TABLE admin.user_properties IS 'Налаштування користувача';
@@ -1,15 +1,16 @@
1
1
  import getSelect from '../../controllers/utils/getSelect.js';
2
- import pg from '../../../pg/pgClients.js';
2
+ import pgClients from '../../../pg/pgClients.js';
3
3
  import redis from '../../../redis/client.js';
4
4
 
5
- export default async function metaFormat({ name, values }) {
5
+ export default async function getSelectVal({ pg: pg1, name, values }) {
6
+ const pg = pg1 || pgClients.client;
6
7
  const cls = await getSelect(name);
7
8
  if (!cls?.arr && !cls?.sql) return null;
8
9
  const key = `select:${name}`;
9
10
  const cache = !cls.arr ? (await redis.hmget(key, values)).reduce((p, el, i) => ({ ...p, [values[i]]: el }), {}) : {};
10
11
 
11
12
  const data = cls.arr || (values.filter(el => !cache[el]).length
12
- ? await pg.client.query(`with c(id,text) as (${cls.sql}) select * from c where id = any('{${values.filter(el => !cache[el])}}')`).then(el => el.rows)
13
+ ? await pg.query(`with c(id,text) as (${cls.sql}) select * from c where id = any('{${values.filter(el => !cache[el])}}')`).then(el => el.rows)
13
14
  : []);
14
15
 
15
16
  const clsAr = { ...cache, ...data.reduce((p, el) => ({ ...p, [el.id.toString()]: el.color ? el : el.text }), {}) };