teambition-sdk-socket
Version:
Front-End SDK for Teambition
43 lines • 1.93 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 Collection_1 = require("../schemas/Collection");
var index_1 = require("../utils/index");
var CollectionModel = (function (_super) {
__extends(CollectionModel, _super);
function CollectionModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._schemaName = 'TBCollection';
return _this;
}
CollectionModel.prototype.addOne = function (collection) {
var result = index_1.dataToSchema(collection, Collection_1.default);
return this._save(result);
};
CollectionModel.prototype.getOne = function (collectionId) {
return this._get(collectionId);
};
CollectionModel.prototype.addCollections = function (_parentId, collections) {
var result = index_1.datasToSchemas(collections, Collection_1.default);
return this._saveCollection("collections/" + _parentId, result, this._schemaName, function (data) {
return data._parentId === _parentId && !data.isArchived;
});
};
CollectionModel.prototype.getCollections = function (_parentId) {
return this._get("collections/" + _parentId);
};
return CollectionModel;
}(BaseModel_1.default));
exports.CollectionModel = CollectionModel;
exports.default = new CollectionModel;
//# sourceMappingURL=CollectionModel.js.map