summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/index.js b/index.js
index c0d0378..bcc6927 100644
--- a/index.js
+++ b/index.js
@@ -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) {