UNPKG

nodejs-rigorous

Version:
25 lines (15 loc) 524 B
/* eslint no-param-reassign:0 */ module.exports = (schema, attributesSettings) => { const primaryKey = {}; let partialKey = false; Object.keys(attributesSettings).forEach((attribute) => { const attributeObject = attributesSettings[attribute]; if (attributeObject.partialPrimaryKey) { partialKey = true; primaryKey[attribute] = 1; } }); if (partialKey) { schema.index(primaryKey, { unique: true }); } };