@live-change/user-service 0.9.71 → 0.9.73

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/model.js +29 -0
  2. package/package.json +4 -4
package/model.js CHANGED
@@ -1,7 +1,11 @@
1
+ import App from '@live-change/framework'
2
+ const app = App.app()
1
3
  import definition from './definition.js'
2
4
 
3
5
  const User = definition.model({
4
6
  name: "User",
7
+ entity: {
8
+ },
5
9
  properties: {
6
10
  roles: {
7
11
  type: Array,
@@ -11,6 +15,10 @@ const User = definition.model({
11
15
  }
12
16
  },
13
17
  indexes: {
18
+ byRole: {
19
+ property: ['roles'],
20
+ multi: true
21
+ }
14
22
  }
15
23
  })
16
24
 
@@ -100,4 +108,25 @@ definition.view({
100
108
  }
101
109
  })
102
110
 
111
+ definition.view({
112
+ name: 'usersByRole',
113
+ internal: true,
114
+ properties: {
115
+ role: {
116
+ type: String,
117
+ validation: ['nonEmpty']
118
+ },
119
+ ...App.rangeProperties
120
+ },
121
+ returns: {
122
+ type: User
123
+ },
124
+ daoPath(params) {
125
+ const { role } = params
126
+ const range = App.extractRange(params)
127
+ if(!range.limit || range.limit > 128) range.limit = 128
128
+ return User.sortedIndexRangePath('byRole', role, range)
129
+ }
130
+ })
131
+
103
132
  export { User, Session, AuthenticatedUser }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/user-service",
3
- "version": "0.9.71",
3
+ "version": "0.9.73",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.71",
26
- "@live-change/relations-plugin": "^0.9.71",
25
+ "@live-change/framework": "^0.9.73",
26
+ "@live-change/relations-plugin": "^0.9.73",
27
27
  "pluralize": "^8.0.0"
28
28
  },
29
- "gitHead": "422e96a7868c9923b55b300821db6e95e5415502"
29
+ "gitHead": "8968fc9d26b0256665e41b6064c71fb4ee728763"
30
30
  }