diff --git a/lib/agent.js b/lib/agent.js index 1154b9b4c..313d2ff45 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -559,6 +559,9 @@ function getSnapshotData(snapshot) { v: snapshot.v, data: snapshot.data }; + if (snapshot.m) { + data.m = snapshot.m; + } if (types.defaultType !== types.map[snapshot.type]) { data.type = snapshot.type; } diff --git a/lib/backend.js b/lib/backend.js index 923dc33b3..e4707fbe8 100644 --- a/lib/backend.js +++ b/lib/backend.js @@ -492,7 +492,7 @@ Backend.prototype.subscribe = function(agent, index, id, version, options, callb if (version == null) { // Subscribing from null means that the agent doesn't have a document // and needs to fetch it as well as subscribing - backend.fetch(agent, index, id, function(err, snapshot) { + backend.fetch(agent, index, id, {snapshotOptions: {metadata: true}}, function(err, snapshot) { if (err) { stream.destroy(); return callback(err); diff --git a/lib/client/doc.js b/lib/client/doc.js index ac6b7881f..c95c1d0a1 100644 --- a/lib/client/doc.js +++ b/lib/client/doc.js @@ -214,6 +214,9 @@ Doc.prototype.ingestSnapshot = function(snapshot, callback) { this.data = (this.type && this.type.deserialize) ? this.type.deserialize(snapshot.data) : snapshot.data; + if (snapshot.m) { + this.meta = snapshot.m; + } this.emit('load'); callback && callback(); };