@superhero/eventflow-db 4.1.3 → 4.2.0
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/index.js
CHANGED
|
@@ -270,32 +270,51 @@ export default class DB
|
|
|
270
270
|
return result
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
async
|
|
273
|
+
async readEventsByDomainAndPidAndNames(domain, pid, names)
|
|
274
274
|
{
|
|
275
|
+
let result
|
|
276
|
+
|
|
275
277
|
try
|
|
276
278
|
{
|
|
277
|
-
|
|
279
|
+
result = await this.gateway.query('event/read-by-pid-domain-names', [ pid, domain, names ])
|
|
280
|
+
}
|
|
281
|
+
catch(reason)
|
|
282
|
+
{
|
|
283
|
+
const error = new Error(`could not read event by pid: ${pid} and domain: ${domain}`)
|
|
284
|
+
error.code = 'E_EVENTFLOW_DB_EVENT_READ_BY_PID'
|
|
285
|
+
error.cause = reason
|
|
286
|
+
throw error
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return result
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async persistEventCpid(event_id, domain, cpid)
|
|
293
|
+
{
|
|
294
|
+
try
|
|
295
|
+
{
|
|
296
|
+
const result = await this.gateway.query('event_cpid/persist', [ event_id, domain, cpid ])
|
|
278
297
|
return result.affectedRows > 0
|
|
279
298
|
}
|
|
280
299
|
catch(reason)
|
|
281
300
|
{
|
|
282
|
-
const error = new Error(`Could not persist event (${event_id}) and cpid (${cpid}) association`)
|
|
301
|
+
const error = new Error(`Could not persist event (${event_id}) and cpid (${domain} › ${cpid}) association`)
|
|
283
302
|
error.code = 'E_EVENTFLOW_DB_EVENT_CPID_PERSIST'
|
|
284
303
|
error.cause = reason
|
|
285
304
|
throw error
|
|
286
|
-
}
|
|
305
|
+
}
|
|
287
306
|
}
|
|
288
307
|
|
|
289
|
-
async deleteEventCpid(event_id, cpid)
|
|
308
|
+
async deleteEventCpid(event_id, domain, cpid)
|
|
290
309
|
{
|
|
291
310
|
try
|
|
292
311
|
{
|
|
293
|
-
const result = await this.gateway.query('event_cpid/delete', [ event_id, cpid ])
|
|
312
|
+
const result = await this.gateway.query('event_cpid/delete', [ event_id, domain, cpid ])
|
|
294
313
|
return result.affectedRows > 0
|
|
295
314
|
}
|
|
296
315
|
catch(reason)
|
|
297
316
|
{
|
|
298
|
-
const error = new Error(`Could not delete event (${event_id}) and cpid (${cpid}) association`)
|
|
317
|
+
const error = new Error(`Could not delete event (${event_id}) and cpid (${domain} › ${cpid}) association`)
|
|
299
318
|
error.code = 'E_EVENTFLOW_DB_EVENT_CPID_DELETE'
|
|
300
319
|
error.cause = reason
|
|
301
320
|
throw error
|
|
@@ -318,7 +337,7 @@ export default class DB
|
|
|
318
337
|
throw error
|
|
319
338
|
}
|
|
320
339
|
|
|
321
|
-
return result.map((
|
|
340
|
+
return result.map(({ domain, cpid }) => ({ domain, cpid }))
|
|
322
341
|
}
|
|
323
342
|
|
|
324
343
|
async readEventsByDomainAndCpid(domain, cpid)
|
|
@@ -329,7 +348,7 @@ export default class DB
|
|
|
329
348
|
}
|
|
330
349
|
catch(reason)
|
|
331
350
|
{
|
|
332
|
-
const error = new Error(`could not read events by
|
|
351
|
+
const error = new Error(`could not read events by: ${domain} › ${cpid}`)
|
|
333
352
|
error.code = 'E_EVENTFLOW_DB_EVENT_BY_DOMAIN_AND_CPID_READ'
|
|
334
353
|
error.cause = reason
|
|
335
354
|
throw error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/eventflow-db",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Eventflow db is a set of common database logic in the eventflow ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eventflow"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@superhero/db": "^0.5.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@superhero/locator": "4.2.
|
|
18
|
+
"@superhero/locator": "4.2.3"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"test-build": "docker ps -q -f name=eventflow-mysql | grep -q . && docker stop eventflow-mysql; docker run --rm --name eventflow-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=eventflow -p 3306:3306 --health-cmd=\"mysqladmin ping -h 127.0.0.1 -uroot -proot --silent || exit 1\" --health-interval=10s --health-timeout=5s --health-retries=5 -d mysql:latest; until [ \"$(docker inspect --format='{{.State.Health.Status}}' eventflow-mysql)\" == \"healthy\" ]; do sleep 1; done",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
CREATE TABLE IF NOT EXISTS event_cpid
|
|
2
2
|
(
|
|
3
3
|
event_id VARCHAR(64) NOT NULL,
|
|
4
|
+
domain VARCHAR(64) NOT NULL,
|
|
4
5
|
cpid VARCHAR(64) NOT NULL,
|
|
5
6
|
|
|
6
|
-
PRIMARY KEY (event_id, cpid),
|
|
7
|
+
PRIMARY KEY (event_id, domain, cpid),
|
|
7
8
|
FOREIGN KEY (event_id) REFERENCES event (id)
|
|
8
9
|
ON UPDATE CASCADE
|
|
9
10
|
ON DELETE CASCADE,
|
|
10
|
-
INDEX
|
|
11
|
+
INDEX idx_domain_cpid (domain, cpid)
|
|
11
12
|
)
|
|
12
13
|
ENGINE=InnoDB
|