Files
notesnook/packages/core/models/notebook.js
2020-03-19 15:14:29 +05:00

42 lines
740 B
JavaScript

import Notebooks from "../collections/notebooks";
import Topics from "../collections/topics";
export default class Notebook {
/**
*
* @param {Notebooks} notebooks
* @param {Object} notebook
*/
constructor(notebooks, notebook) {
this._notebook = notebook;
this._notebooks = notebooks;
}
get title() {
return this._notebook.title;
}
get data() {
return this._notebook;
}
get topics() {
return new Topics(this._notebooks, this._notebook.id);
}
get dateEdited() {
return this._notebook.dateEdited;
}
_toggle(prop) {
return this._notebooks.add({
id: this._notebook.id,
[prop]: !this._notebook[prop]
});
}
pin() {
return this._toggle("pinned");
}
}