@jcbuisson/express-x 1.0.10 → 1.0.11

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +45 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
package/src/index.mjs CHANGED
@@ -21,30 +21,50 @@ function expressX(app) {
21
21
  */
22
22
  function createDatabaseService(name, { entity=name, client='prisma' }) {
23
23
  return createService(name, {
24
- create: (data) => prisma[entity].create({
25
- data,
26
- }),
27
-
28
- get: (id) => prisma[entity].findUnique({
29
- where: {
30
- id,
31
- },
32
- }),
33
-
34
- patch: (id, data) => prisma[entity].update({
35
- where: {
36
- id,
37
- },
38
- data,
39
- }),
40
-
41
- remove: (id, data) => prisma[entity].delete({
42
- where: {
43
- id,
44
- },
45
- }),
46
-
47
- find: (options) => prisma[entity].findMany(options),
24
+ create: (data) => {
25
+ if (isDebug) console.log('create', name, data)
26
+ return prisma[entity].create({
27
+ data,
28
+ })
29
+ },
30
+
31
+ get: (id) => {
32
+ if (isDebug) console.log('get', name, id)
33
+ return prisma[entity].findUnique({
34
+ where: {
35
+ id,
36
+ },
37
+ })
38
+ },
39
+
40
+ patch: (id, data) => {
41
+ if (isDebug) console.log('patch', name, id, data)
42
+ return prisma[entity].update({
43
+ where: {
44
+ id,
45
+ },
46
+ data,
47
+ })
48
+ },
49
+
50
+ remove: (id) => {
51
+ if (isDebug) console.log('remove', name, id)
52
+ return prisma[entity].delete({
53
+ where: {
54
+ id,
55
+ },
56
+ })
57
+ },
58
+
59
+ find: (options) => {
60
+ if (isDebug) console.log('find', name, options)
61
+ return prisma[entity].findMany(options)
62
+ },
63
+
64
+ upsert: (options) => {
65
+ if (isDebug) console.log('upsert', name, options)
66
+ return prisma[entity].upsert(options)
67
+ },
48
68
  })
49
69
  }
50
70
 
@@ -216,7 +236,7 @@ function expressX(app) {
216
236
  if (isDebug) console.log('service-event', name, action, channelName)
217
237
  const connectionList = Object.values(connections).filter(cnx => cnx.channelNames.has(channelName))
218
238
  for (const connection of connectionList) {
219
- if (isDebug) console.log('emit to', connection.id)
239
+ if (isDebug) console.log('emit to', connection.id, name, action, result)
220
240
  connection.socket.emit('service-event', {
221
241
  name,
222
242
  action,