teambition-sdk-socket
Version:
Front-End SDK for Teambition
52 lines • 2.29 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var BaseModel_1 = require("./BaseModel");
var BaseCollection_1 = require("./BaseCollection");
var HomeActivity_1 = require("../schemas/HomeActivity");
var index_1 = require("../utils/index");
var HomeActivityModel = (function (_super) {
__extends(HomeActivityModel, _super);
function HomeActivityModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._schemaName = 'HomeActivity';
return _this;
}
HomeActivityModel.prototype.addOne = function (activity) {
var result = index_1.dataToSchema(activity, HomeActivity_1.default);
return this._save(result);
};
HomeActivityModel.prototype.add = function (_projectId, activities, page) {
var dbIndex = "homeActivities/" + _projectId;
var result = index_1.datasToSchemas(activities, HomeActivity_1.default);
var collection = this._collections.get(dbIndex);
if (!collection) {
collection = new BaseCollection_1.default(this._schemaName, function (data) {
return data.rootId === "project#" + _projectId;
}, dbIndex);
this._collections.set(dbIndex, collection);
}
return collection.addPage(page, result);
};
HomeActivityModel.prototype.get = function (_projectId, page) {
var dbIndex = "homeActivities/" + _projectId;
var collection = this._collections.get(dbIndex);
if (collection) {
return collection.get(page);
}
return null;
};
return HomeActivityModel;
}(BaseModel_1.default));
exports.HomeActivityModel = HomeActivityModel;
exports.default = new HomeActivityModel;
//# sourceMappingURL=HomeActivityModel.js.map