Skip to content

Commit f8616db

Browse files
noahsilasTylerBrock
authored andcommitted
Fix graph pipeline for prefixed databases
This fixes the test suite, which uses a collection prefix of `test_`.
1 parent 73510b1 commit f8616db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Auth.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Auth.prototype._loadUserRolesForAccess = async function () {
218218
};
219219

220220
Auth.prototype._generateRoleGraphPipeline = function () {
221+
const prefix = this.config.database.adapter._collectionPrefix;
221222
return [
222223
{
223224
$match: {
@@ -226,7 +227,7 @@ Auth.prototype._generateRoleGraphPipeline = function () {
226227
},
227228
{
228229
$graphLookup: {
229-
from: '_Join:roles:_Role',
230+
from: `${prefix}_Join:roles:_Role`,
230231
startWith: '$owningId',
231232
connectFromField: 'owningId',
232233
connectToField: 'relatedId',
@@ -238,7 +239,7 @@ Auth.prototype._generateRoleGraphPipeline = function () {
238239
directRoles: [
239240
{
240241
$lookup: {
241-
from: '_Role',
242+
from: `${prefix}_Role`,
242243
localField: 'owningId',
243244
foreignField: '_id',
244245
as: 'Roles',
@@ -265,7 +266,7 @@ Auth.prototype._generateRoleGraphPipeline = function () {
265266
childRoles: [
266267
{
267268
$lookup: {
268-
from: '_Role',
269+
from: `${prefix}_Role`,
269270
localField: 'childRolePath.owningId',
270271
foreignField: '_id',
271272
as: 'Roles',

0 commit comments

Comments
 (0)