Skip to content

Commit 867fc96

Browse files
Ensure indexes for Roles and Subjects collections as part of boot (nightscout#7902)
* Allow DELETE via PATCH/UPDATE operation too * rollback wrong commit * Ensure indexes for Roles and Subjects collections as part of boot --------- Co-authored-by: Milos Kozak <[email protected]>
1 parent a4d07cd commit 867fc96

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/authorization/storage.js

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ function init (env, ctx) {
122122
, { name: 'activity', permissions: [ 'api:activity:create' ] }
123123
];
124124

125+
storage.ensureIndexes = function ensureIndexes() {
126+
ctx.store.ensureIndexes(rolesCollection, ['name']);
127+
ctx.store.ensureIndexes(subjectsCollection, ['name']);
128+
}
129+
125130
storage.getSHA1 = function getSHA1 (message) {
126131
var shasum = crypto.createHash('sha1');
127132
shasum.update(message);

lib/server/bootevent.js

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function boot (env, language) {
185185
}
186186

187187
ctx.authorization = require('../authorization')(env, ctx);
188+
ctx.authorization.storage.ensureIndexes();
188189
ctx.authorization.storage.reload(function loaded (err) {
189190
if (err) {
190191
ctx.bootErrors = ctx.bootErrors || [ ];

0 commit comments

Comments
 (0)