@nsshunt/stsdatamanagement 1.18.101 → 1.18.102

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/README.md CHANGED
@@ -68,7 +68,8 @@ WHERE (resdesc_jsonb#>'{_resourceType}')::text = '"Person"';
68
68
  SELECT *
69
69
  FROM stsresource
70
70
  WHERE resdesc_jsonb @> '{"_resourceType": "Person"}'
71
- AND resdesc_jsonb @> '{"name": [{"family": "Adams"}]}';
71
+ AND resdesc_jsonb @> '{"name": [{"family": "Adams"}]}'
72
+ LIMIT 20
72
73
 
73
74
  SELECT oid, resdesc_jsonb#>'{text,div}' AS text_div
74
75
  FROM stsresource
@@ -96,13 +97,13 @@ WHERE resdesc_jsonb->>'_resourceType' = 'Person'
96
97
  /* Get record using the BTREE index 02 */
97
98
  SELECT oid, resdesc_jsonb#>'{text,div}' AS text_div
98
99
  FROM stsresource
99
- WHERE resdesc_jsonb->>'_resourceType' = 'Person'
100
+ WHERE (resdesc_jsonb#>'{_resourceType}')::text = '"Person"'
100
101
  AND resdesc_jsonb#>'{text,div}' = '"New Record 400"';
101
-
102
+
102
103
  /* Query using id index */
103
104
  SELECT oid, resdesc_jsonb->>'id' as id, *
104
105
  FROM stsresource
105
- WHERE resdesc_jsonb->>'id' >= '_b' and resdesc_jsonb->>'id' < '_bzzzzzzzzzzzz'
106
+ WHERE resdesc_jsonb->>'id' >= '_' and resdesc_jsonb->>'id' < '_zzzzzzzzzzzz'
106
107
  ORDER BY resdesc_jsonb->>'id'
107
108
  LIMIT 20;
108
109
 
@@ -119,6 +120,16 @@ FROM (
119
120
  ORDER BY given DESC
120
121
  LIMIT 20;
121
122
 
123
+ /* Query using family indexes */
124
+ SELECT distinct resdesc_jsonb->'name'->0->>'given' as given, resdesc_jsonb->'name'->0->>'family' as family
125
+ FROM stsresource
126
+ WHERE resdesc_jsonb->>'_resourceType' = 'Person'
127
+ AND validto is null
128
+ AND resdesc_jsonb->'name'->0->>'family' >= 'y'
129
+ AND resdesc_jsonb->'name'->0->>'family' < 'yzzzzzzzzzzzz'
130
+ ORDER BY given DESC
131
+ LIMIT 20
132
+
122
133
  /* Query using family and given indexes */
123
134
  SELECT distinct given, family
124
135
  FROM (
@@ -134,3 +145,12 @@ FROM (
134
145
  ORDER BY given DESC
135
146
  LIMIT 20;
136
147
 
148
+ /* Query using given indexes */
149
+ select count(*) from (
150
+ SELECT distinct resdesc_jsonb->'name'->0->>'given' as given
151
+ FROM stsresource
152
+ WHERE validto is null
153
+ AND resdesc_jsonb->>'_resourceType' = 'Person'
154
+ AND resdesc_jsonb->'name'->0->>'given' >= 'al'
155
+ AND resdesc_jsonb->'name'->0->>'given' < 'alzzzzzzz'
156
+ )
@@ -38,6 +38,8 @@ CREATE TABLE public.stsresource
38
38
  resname character varying(128) COLLATE pg_catalog."default" NOT NULL,
39
39
  resdesc character varying(32768) COLLATE pg_catalog."default",
40
40
  resdesc_jsonb jsonb,
41
+ given character varying(64) COLLATE pg_catalog."default",
42
+ family character varying(64) COLLATE pg_catalog."default",
41
43
  vnum bigint NOT NULL,
42
44
  validfrom timestamp with time zone NOT NULL,
43
45
  validto timestamp with time zone,
@@ -68,6 +70,21 @@ CREATE INDEX stsresource_resname_validto
68
70
  TABLESPACE pg_default;
69
71
 
70
72
 
73
+ -- DROP INDEX public.stsresource_given;
74
+
75
+ CREATE INDEX stsresource_given
76
+ ON public.stsresource USING btree
77
+ (given COLLATE pg_catalog."default" ASC NULLS LAST)
78
+ TABLESPACE pg_default;
79
+
80
+ -- DROP INDEX public.stsresource_family;
81
+
82
+ CREATE INDEX stsresource_family
83
+ ON public.stsresource USING btree
84
+ (family COLLATE pg_catalog."default" ASC NULLS LAST)
85
+ TABLESPACE pg_default;
86
+
87
+
71
88
  -- FUNCTION: public.create_stsresource(character varying, character varying, character varying)
72
89
 
73
90
  -- DROP FUNCTION public.create_stsresource(character varying, character varying, character varying);
@@ -91,9 +108,13 @@ DECLARE
91
108
  __dbaction smallint;
92
109
  __inserted_oid bigint;
93
110
  _resdesc_jsonb JSONB;
111
+ _given character varying(64) COLLATE pg_catalog."default";
112
+ _family character varying(64) COLLATE pg_catalog."default";
94
113
  BEGIN
95
114
  begin
96
115
  _resdesc_jsonb := _resdesc::jsonb;
116
+ _given := _resdesc_jsonb->'name'->0->>'given';
117
+ _family := _resdesc_jsonb->'name'->0->>'_family';
97
118
  exception
98
119
  when others then
99
120
  raise exception 'Invalid JSON string: %', _resdesc;
@@ -114,8 +135,8 @@ BEGIN
114
135
  update stsresource set validto = __now where oid = __resoid;
115
136
 
116
137
  -- Create a new record
117
- insert into stsresource(resname, resdesc, resdesc_jsonb, vnum, dbaction, dbactionuser, validfrom)
118
- values (_resname, _resdesc, _resdesc_jsonb, __vnum+1, 1, _dbactionuser, __now)
138
+ insert into stsresource(resname, resdesc, resdesc_jsonb, given, family, vnum, dbaction, dbactionuser, validfrom)
139
+ values (_resname, _resdesc, _resdesc_jsonb, _given, _family, __vnum+1, 1, _dbactionuser, __now)
119
140
  returning oid into __inserted_oid;
120
141
 
121
142
  return query
@@ -135,8 +156,8 @@ BEGIN
135
156
  returning *;
136
157
  */
137
158
 
138
- insert into stsresource(resname, resdesc, resdesc_jsonb, vnum, dbaction, dbactionuser, validfrom)
139
- values (_resname, _resdesc, _resdesc_jsonb, 1, 1, _dbactionuser, __now)
159
+ insert into stsresource(resname, resdesc, resdesc_jsonb, given, family, vnum, dbaction, dbactionuser, validfrom)
160
+ values (_resname, _resdesc, _resdesc_jsonb, _given, _family, 1, 1, _dbactionuser, __now)
140
161
  returning oid into __inserted_oid;
141
162
 
142
163
  return query
@@ -171,9 +192,13 @@ declare
171
192
  resoid bigint;
172
193
  newresoid stsresource.oid%TYPE;
173
194
  _resdesc_jsonb JSONB;
195
+ _given character varying(64) COLLATE pg_catalog."default";
196
+ _family character varying(64) COLLATE pg_catalog."default";
174
197
  BEGIN
175
198
  begin
176
199
  _resdesc_jsonb := _resdesc::jsonb;
200
+ _given := _resdesc_jsonb->'name'->0->>'given';
201
+ _family := _resdesc_jsonb->'name'->0->>'_family';
177
202
  exception
178
203
  when others then
179
204
  raise exception 'Invalid JSON string: %', _resdesc;
@@ -193,8 +218,8 @@ BEGIN
193
218
 
194
219
  update stsresource set validto = _now where oid = resoid;
195
220
 
196
- insert into stsresource(resname, resdesc, resdesc_jsonb, vnum, dbaction, dbactionuser, validfrom)
197
- values (_resname, _resdesc, _resdesc_jsonb, _resvnum+1, 2, _dbactionuser, _now)
221
+ insert into stsresource(resname, resdesc, resdesc_jsonb, given, family, vnum, dbaction, dbactionuser, validfrom)
222
+ values (_resname, _resdesc, _resdesc_jsonb, _given, _family, _resvnum+1, 2, _dbactionuser, _now)
198
223
  RETURNING oid INTO newresoid;
199
224
 
200
225
  update stsentity set resourceoid = newresoid where resourceoid = resoid;
@@ -230,9 +255,13 @@ declare
230
255
  newresoid stsresource.oid%TYPE;
231
256
  _resvnum integer;
232
257
  _resdesc_jsonb JSONB;
258
+ _given character varying(64) COLLATE pg_catalog."default";
259
+ _family character varying(64) COLLATE pg_catalog."default";
233
260
  BEGIN
234
261
  begin
235
262
  _resdesc_jsonb := _resdesc::jsonb;
263
+ _given := _resdesc_jsonb->'name'->0->>'given';
264
+ _family := _resdesc_jsonb->'name'->0->>'_family';
236
265
  exception
237
266
  when others then
238
267
  raise exception 'Invalid JSON string: %', _resdesc;
@@ -259,8 +288,8 @@ BEGIN
259
288
 
260
289
  update stsresource set validto = _now where oid = resoid;
261
290
 
262
- insert into stsresource(resname, resdesc, resdesc_jsonb, vnum, dbaction, dbactionuser, validfrom)
263
- values (_resname, _resdesc, _resdesc_jsonb, _resvnum+1, 2, _dbactionuser, _now)
291
+ insert into stsresource(resname, resdesc, resdesc_jsonb, given, family, vnum, dbaction, dbactionuser, validfrom)
292
+ values (_resname, _resdesc, _resdesc_jsonb, _given, _family, _resvnum+1, 2, _dbactionuser, _now)
264
293
  RETURNING oid INTO newresoid;
265
294
 
266
295
  update stsentity set resourceoid = newresoid where resourceoid = resoid;
@@ -310,8 +339,8 @@ BEGIN
310
339
 
311
340
  update stsresource set validto = _now where oid = resoid;
312
341
 
313
- insert into stsresource(resname, resdesc, resdesc_jsonb, vnum, dbaction, dbactionuser, validfrom)
314
- select r.resname, r.resdesc, r.resdesc::jsonb, _resvnum+1, 3, _dbactionuser, _now
342
+ insert into stsresource(resname, resdesc, resdesc_jsonb, given, family, vnum, dbaction, dbactionuser, validfrom)
343
+ select r.resname, r.resdesc, r.resdesc::jsonb, resdesc_jsonb->'name'->0->>'given', resdesc_jsonb->'name'->0->>'family', _resvnum+1, 3, _dbactionuser, _now
315
344
  from stsresource r where r.oid = resoid
316
345
  RETURNING oid INTO newresoid;
317
346
 
@@ -365,8 +394,8 @@ BEGIN
365
394
 
366
395
  update stsresource set validto = _now where oid = resoid;
367
396
 
368
- insert into stsresource(resname, resdesc, resdesc_jsonb, vnum, dbaction, dbactionuser, validfrom)
369
- select r.resname, r.resdesc, r.resdesc::jsonb, _resvnum+1, 3, _dbactionuser, _now
397
+ insert into stsresource(resname, resdesc, resdesc_jsonb, given, family, vnum, dbaction, dbactionuser, validfrom)
398
+ select r.resname, r.resdesc, r.resdesc::jsonb, resdesc_jsonb->'name'->0->>'given', resdesc_jsonb->'name'->0->>'family', _resvnum+1, 3, _dbactionuser, _now
370
399
  from stsresource r where r.oid = resoid
371
400
  RETURNING oid INTO newresoid;
372
401
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsdatamanagement",
3
- "version": "1.18.101",
3
+ "version": "1.18.102",
4
4
  "description": "STS Data Management Modules, Utilities and Services",
5
5
  "main": "./dist/dbaccess.js",
6
6
  "types": "./types/dbaccess.d.ts",