mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 22:19:41 +01:00
41 lines
675 B
JavaScript
41 lines
675 B
JavaScript
import Topics from "../collections/topics";
|
|
|
|
export default class Notebook {
|
|
/**
|
|
*
|
|
* @param {Object} notebook
|
|
* @param {import ('../api').default} db
|
|
*/
|
|
constructor(notebook, db) {
|
|
this._notebook = notebook;
|
|
this._db = db;
|
|
}
|
|
|
|
get title() {
|
|
return this._notebook.title;
|
|
}
|
|
|
|
get data() {
|
|
return this._notebook;
|
|
}
|
|
|
|
get topics() {
|
|
return new Topics(this._notebook.id, this._db);
|
|
}
|
|
|
|
get dateEdited() {
|
|
return this._notebook.dateEdited;
|
|
}
|
|
|
|
_toggle(prop) {
|
|
return this._db.notebooks.add({
|
|
id: this._notebook.id,
|
|
[prop]: !this._notebook[prop],
|
|
});
|
|
}
|
|
|
|
pin() {
|
|
return this._toggle("pinned");
|
|
}
|
|
}
|