Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new Error(`In registerPlugin, collection "${collectionKey}" needs a name property`);
}
// Validate that the `collections` key hasn't already been taken by another plugin
if (this.collections[collectionKey]) {
throw new Error(`Plugin ${pluginName} defines a collection with key "${collectionKey}" in registerPlugin,` +
" but another plugin has already defined a collection with that key");
}
// Add the collection instance to `context.collections`
this.collections[collectionKey] = this.db.collection(collectionConfig.name);
// If the collection config has `indexes` key, define all requested indexes
if (Array.isArray(collectionConfig.indexes)) {
for (const indexArgs of collectionConfig.indexes) {
collectionIndex(this.collections[collectionKey], ...indexArgs);
}
}
}
}
}
}
}
}