diff options
-rw-r--r-- | index.js | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -8,15 +8,21 @@ function fromObject(root) { root.collection = _.isObject(root.collection) ? root.collection : {}; var c = root.collection; c.version = _.isString(c.version) ? c.version : "1.0"; - c.items = _.isArray(c.items) ? c.items : []; - c.links = _.isArray(c.links) ? c.links : []; - c.queries = _.isArray(c.queries) ? c.queries : []; - c.templates = _.isArray(c.templates) ? c.templates : []; + c.items = _.isArray(c.items) ? c.items : []; _.each(c.items, function(item) { item.links = _.isArray(item.links) ? item.links : []; }); + c.links = _.isArray(c.links) ? c.links : []; + + c.queries = _.isArray(c.queries) ? c.queries : []; + _.each(c.queries, function(query) { + query.data = _.isArray(query.data) ? query.data : []; + }); + + c.templates = _.isArray(c.templates) ? c.templates : []; + // TODO: make un-enumerable root.mapItemData = function(f) { return _.map(this.collection.items, function(item) { |