@becomes/cms
Version:
Simple CMS for building APIs.
39 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryFactory = void 0;
var entry_model_1 = require("../models/entry.model");
var mongoose_1 = require("mongoose");
var prop_1 = require("../../prop");
var EntryFactory = (function () {
function EntryFactory() {
}
Object.defineProperty(EntryFactory, "instance", {
get: function () {
return new entry_model_1.Entry(new mongoose_1.Types.ObjectId(), Date.now(), Date.now(), '', '', []);
},
enumerable: false,
configurable: true
});
EntryFactory.objectToEntry = function (object) {
var entry = new entry_model_1.Entry(new mongoose_1.Types.ObjectId(), Date.now(), Date.now(), '', '', []);
return entry;
};
EntryFactory.toLite = function (entry) {
var result = JSON.parse(JSON.stringify(entry));
result.content.forEach(function (e) {
e.props = e.props
.filter(function (t) { return t.type === prop_1.PropType.QUILL; })
.map(function (t) {
if (t.type === prop_1.PropType.QUILL) {
t.value = t.value;
t.value.content = [];
}
return t;
});
});
return result;
};
return EntryFactory;
}());
exports.EntryFactory = EntryFactory;
//# sourceMappingURL=entry.factory.js.map