UNPKG

nodejs-rigorous

Version:
21 lines (18 loc) 477 B
"use strict"; /* 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 }); } };