Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt db prefix enhancement for more integrations #3985

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
32 changes: 22 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var Keystone = function () {
'logger': ':method :url :status :response-time ms',
'auto update': false,
'model prefix': null,
'db opt': null,
'module root': moduleRoot,
'frame guard': 'sameorigin',
'cache admin bundles': true,
Expand Down Expand Up @@ -72,11 +73,19 @@ var Keystone = function () {
this.set('allowed ip ranges', process.env.ALLOWED_IP_RANGES);

if (process.env.S3_BUCKET && process.env.S3_KEY && process.env.S3_SECRET) {
this.set('s3 config', { bucket: process.env.S3_BUCKET, key: process.env.S3_KEY, secret: process.env.S3_SECRET, region: process.env.S3_REGION });
this.set('s3 config', {
bucket: process.env.S3_BUCKET,
key: process.env.S3_KEY,
secret: process.env.S3_SECRET,
region: process.env.S3_REGION
});
}

if (process.env.AZURE_STORAGE_ACCOUNT && process.env.AZURE_STORAGE_ACCESS_KEY) {
this.set('azurefile config', { account: process.env.AZURE_STORAGE_ACCOUNT, key: process.env.AZURE_STORAGE_ACCESS_KEY });
this.set('azurefile config', {
account: process.env.AZURE_STORAGE_ACCOUNT,
key: process.env.AZURE_STORAGE_ACCESS_KEY
});
}

if (process.env.CLOUDINARY_URL) {
Expand Down Expand Up @@ -104,8 +113,11 @@ Keystone.prototype.prefixModel = function (key) {
if (modelPrefix) {
key = modelPrefix + '_' + key;
}

return require('mongoose/lib/utils').toCollectionName(key);
if (_.isObject(this.get('db opt'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name doesn't seem descriptive enough for what it does

return require('mongoose/lib/utils').toCollectionName(key, this.get('db opt'));
} else {
return require('mongoose/lib/utils').toCollectionName(key);
}
};

/* Attach core functionality to Keystone.prototype */
Expand Down Expand Up @@ -139,12 +151,12 @@ Keystone.prototype.routes = function () {
var keystone = module.exports = new Keystone();

/*
Note: until #1777 is complete, the order of execution here with the requires
(specifically, they happen _after_ the module.exports above) is really
important. As soon as the circular dependencies are sorted out to get their
keystone instance from a closure or reference on {this} we can move these
bindings into the Keystone constructor.
*/
Note: until #1777 is complete, the order of execution here with the requires
(specifically, they happen _after_ the module.exports above) is really
important. As soon as the circular dependencies are sorted out to get their
keystone instance from a closure or reference on {this} we can move these
bindings into the Keystone constructor.
*/

// Expose modules and Classes
keystone.Admin = {
Expand Down