Closed
Description
I recently requested metadata to be included in sharedb-mongo and it was made possible shortly after by adding an options
parameter.
However, I'm not quite sure how to actually get the metadata out. The options
parameter was added to ShareDbMongo.prototype.getOps
:
ShareDbMongo.prototype.getOps = function(collectionName, id, from, to, options, callback) {
var self = this;
this._getSnapshotOpLink(collectionName, id, function(err, doc) {
if (err) return callback(err);
if (doc) {
if (isCurrentVersion(doc, from)) {
return callback(null, []);
}
var err = doc && checkDocHasOp(collectionName, id, doc);
if (err) return callback(err);
}
self._getOps(collectionName, id, from, options, function(err, ops) {
if (err) return callback(err);
var filtered = filterOps(ops, doc, to);
var err = checkOpsFrom(collectionName, id, filtered, from);
if (err) return callback(err);
callback(null, filtered);
});
});
};
But unfortuntaely, the options don't seem to be passed over from ShareDB itself. Backend.prototype.getOps
does not take any options
parameter and just passes through null
as options to sharedb-mongo (through backend.db.getOps
):
Backend.prototype.getOps = function(agent, index, id, from, to, callback) {
var start = Date.now();
var projection = this.projections[index];
var collection = (projection) ? projection.target : index;
var backend = this;
var request = {
agent: agent,
index: index,
collection: collection,
id: id,
from: from,
to: to
};
backend.db.getOps(collection, id, from, to, null, function(err, ops) {
if (err) return callback(err);
backend._sanitizeOps(agent, projection, collection, id, ops, function(err) {
if (err) return callback(err);
backend.emit('timing', 'getOps', Date.now() - start, request);
callback(err, ops);
});
});
};
How am I supposed to pass options (to get metadata) to sharedb-mongo without modifying the ShareDB source code?
Metadata
Metadata
Assignees
Labels
No labels