diff --git a/packages/isomorphic-core/src/delta-stream-builder.js b/packages/isomorphic-core/src/delta-stream-builder.js index edbd5dce0..5b9b91491 100644 --- a/packages/isomorphic-core/src/delta-stream-builder.js +++ b/packages/isomorphic-core/src/delta-stream-builder.js @@ -3,7 +3,7 @@ const Rx = require('rx') const stream = require('stream'); function stringifyTransactions(db, transactions = []) { - const transactionJSONs = transactions.map((t) => t.toJSON()) + const transactionJSONs = transactions.map((t) => (t.toJSON ? t.toJSON() : t)) transactionJSONs.forEach((t) => { t.cursor = t.id }); const byModel = _.groupBy(transactionJSONs, "object"); @@ -57,7 +57,7 @@ module.exports = { buildCursor({databasePromise}) { return databasePromise.then(({Transaction}) => { return Transaction.findOne({order: [['id', 'DESC']]}).then((t) => { - return (t || {}).id; + return t ? t.id : 0; }); }); },