Skip to content

getOps does not include metadata, specifically timestamps. #42

Closed
@kbadk

Description

@kbadk

getOps does no longer includes metadata as ShareJS (and LiveDB Mongo does).

When looking at the current implementation of _getOps, we can see that the metadata (m field) is deliberately being removed:

ShareDbMongo.prototype._getOps = function(collectionName, id, from, callback) {
  this.getOpCollection(collectionName, function(err, opCollection) {
    if (err) return callback(err);
    var query = getOpsQuery(id, from);
    // Exclude the `d` field, which is only for use internal to livedb-mongo.
    // Also exclude the `m` field, which can be used to store metadata on ops
    // for tracking purposes
    var projection = {d: 0, m: 0};
    var sort = {v: 1};
    opCollection.find(query).project(projection).sort(sort).toArray(callback);
  });
};

This did not happen in LiveDB Mongo:

LiveDbMongo.prototype.getOps = function(cName, docName, start, end, callback) {
  var err; if (err = this._check(cName)) return callback(err);

  var query = end == null ? {$gte:start} : {$gte:start, $lt:end};
  this._opCollection(cName).find({name:docName, v:query}, {sort:{v:1}}).toArray(function(err, data) {
    if (err) return callback(err);

    for (var i = 0; i < data.length; i++) {
      // Strip out _id in the results
      delete data[i]._id;
      delete data[i].name;
    }
    callback(null, data);
  });
};

Could this be reverted, or could there possibly be an option to allow users to fetch the operations along with metadata?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions