2

嗨,我在重写 mapReduce 时遇到了困难,因为它在 aws documentdb 中不受支持,任何解决方法都将不胜感激

var historyMap = function () {
            var values = {
                updateType: this.updateType.name + '(v.' + this.version + ')',
                version: this.version,
                revisionTimestamp: this.revisionTimestamp,
                entityId: this.entityId
            };
            emit(this.entityId, values);
        };
        var scenarioMap = function () {
            emit(this._id, {friendlyId: this.friendlyId});
        };
        var reduce = function (key, values) {
            var updateTypes = '';
            var friendlyId = '';
            if (values[0].revisionTimestamp !== 'undefined') {
                var revisionTimestamp = values[values.length - 1].revisionTimestamp;
            }
            values.forEach(function (value) {
                if (value.updateType) {
                    updateTypes += value.updateType + ',';
                }
                if (value.friendlyId) {
                    friendlyId = value.friendlyId;
                }
            });
            return {updateType: updateTypes, entityId: key, friendlyId: friendlyId, revisionTimestamp: revisionTimestamp};
        };

HistoryReport.find({}).remove().exec().then(function () {
        History.mapReduce({
            map: historyMap,
            reduce: reduce,
            query: {type: 'Scenario', revisionTimestamp: {$gte: startDate, $lt: endDate}},
            out: {'reduce': historyReportCollectionName},
            sort: {revisionTimestamp: -1}
        }, function () {
            Scenario.mapReduce({
                map: scenarioMap,
                reduce: reduce,
                out: {'reduce': historyReportCollectionName}
            }, function () {
                HistoryReport.find({'value.updateType': {'$exists': true}}).exec().then(function (data) {
                    populateSheet(data);
                });
            });
        });
    }).then(null, function (err) {
        next(new errorHandler.error.ProcessingError(errorHandler.getErrorMessage(err)));
    });

我收到以下错误 MongoError {name: "MongoError", message: "Feature not supported: mapreduce", ok: 0, errmsg: "Feature not supported: mapreduce", code: 303, ...}code: 303errmsg: "Feature不支持:mapreduce”消息:“功能不支持:mapreduce”名称:“MongoError”ok:0

4

0 回答 0