From 34f1ca02bea38e0b7ef185ebf07d3ec6df30f370 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 13 Apr 2015 17:57:17 -0400 Subject: split up the projects by category, add a schema flag so we can use the same singular template --- app/index.js | 6 +++--- app/node_modules/okquery/index.js | 6 ++++++ app/node_modules/okview/index.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/index.js b/app/index.js index 419adfc..7860f76 100644 --- a/app/index.js +++ b/app/index.js @@ -87,7 +87,6 @@ function OKCMS(options) { this._createResources(resourceConfig, db, schemas); var errorHandler = createErrorHandlerProducer( templateProvider, adminTemplateProvider, debug); - // Create view instances from config var views = this._views = this._createViews(viewConfig, db, meta, resourceCache, templateProvider, @@ -141,7 +140,7 @@ OKCMS.prototype._createResources = function(resourceConfig, db, schemaCache) { var type = config.type; var schema = schemaCache[type]; if (!schema) - throw new Error('Resource config references nonexistent schema'); + throw new Error('Resource config references nonexistent schema ' + type); var resource = OKResource({ type: type, db: db, @@ -244,7 +243,8 @@ OKCMS.prototype._createQueries = function(queryConfig, resourceCache) { var query = config.query || '*'; return new OKQuery({ resource: resource, - query: query + query: query, + as: config.as, }); }); }; diff --git a/app/node_modules/okquery/index.js b/app/node_modules/okquery/index.js index 9cc8b78..519bc08 100644 --- a/app/node_modules/okquery/index.js +++ b/app/node_modules/okquery/index.js @@ -33,6 +33,12 @@ function OKQuery(options) { enumerable: true }); + Object.defineProperty(this, 'as', { + value: options.as, + writable: false, + enumerable: true + }); + this.get = createQuery(resource, query, { default: options.default }); diff --git a/app/node_modules/okview/index.js b/app/node_modules/okview/index.js index 63f22b5..951261c 100644 --- a/app/node_modules/okview/index.js +++ b/app/node_modules/okview/index.js @@ -139,7 +139,7 @@ function fetchTemplateData(meta, queries, id) { return cache; } var resource = queries[i].resource; - var type = queries[i].type; + var type = queries[i].as || queries[i].type; var manyResult = isarray(result); // Inform template of ID in generic field if (manyResult) { -- cgit v1.2.3-70-g09d2