nodejs-rigorous
Version:
Rigorous Framework
21 lines (18 loc) • 477 B
JavaScript
;
/* eslint no-param-reassign:0 */
module.exports = function (schema, attributesSettings) {
var primaryKey = {};
var partialKey = false;
Object.keys(attributesSettings).forEach(function (attribute) {
var attributeObject = attributesSettings[attribute];
if (attributeObject.partialPrimaryKey) {
partialKey = true;
primaryKey[attribute] = 1;
}
});
if (partialKey) {
schema.index(primaryKey, {
unique: true
});
}
};