From 5ab6fdbb5a8b65f6a8b1af9bd5fb18bf5b555d8a Mon Sep 17 00:00:00 2001 From: Sjoerd de Jong Date: Wed, 27 Aug 2014 16:37:25 +0200 Subject: [PATCH] Handle empty relations relational-pouch requires non empty relations objects, see https://github.com/nolanlawson/relational-pouch/blob/8955f2dab1b137fd30adae801fcd1e72b1742cfd/lib/index.js#L78-L80. This fix allows for records without any relations to other records. --- lib/pouchdb-adapter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pouchdb-adapter.js b/lib/pouchdb-adapter.js index 3cabe86..f6d24e0 100644 --- a/lib/pouchdb-adapter.js +++ b/lib/pouchdb-adapter.js @@ -23,8 +23,7 @@ export default DS.RESTAdapter.extend({ var schemaDef = { singular: singular, - plural: plural, - relations: {} + plural: plural }; // else it's new, so update @@ -38,6 +37,9 @@ export default DS.RESTAdapter.extend({ } var relDef = {}; relDef[rel.kind] = rel.type.typeKey; + if (!schemaDef.relations) { + schemaDef.relations = {}; + } schemaDef.relations[rel.key] = relDef; self._init(rel.type); });