diff options
Diffstat (limited to 'app/index.js')
| -rw-r--r-- | app/index.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/index.js b/app/index.js index 29dcfd0..6d057d3 100644 --- a/app/index.js +++ b/app/index.js @@ -56,19 +56,22 @@ OKCMS.prototype._createSchemas = function(schemaConfig) { OKCMS.prototype._createResources = function(resourceConfig, db, schemaCache) { resourceConfig = resourceConfig || {}; - return resourceConfig.map(function(config) { + var typeCache = {}; + return resourceConfig.reduce(function(cache, config) { var type = config.type; var schema = schemaCache[type]; if (!schema) throw new Error('Resource config references nonexistent schema'); - // If no id is provided, default to "select all" - var id = config.id || '*'; - return OKResource({ + // If we already created resource class, just skip + if (cache[type]) + return cache; + cache[type] = OKResource({ type: type, - id: id, + db: db, schema: schema }) - }); + return cache; + }, {}); }; OKCMS.prototype._createViews = function(viewConfig, db, |
