2020-02-03 12:03:07 +05:00
|
|
|
import Notes from "../collections/notes";
|
2020-04-13 12:46:29 +05:00
|
|
|
import Storage from "../database/storage";
|
2020-02-04 18:27:32 +05:00
|
|
|
import Notebooks from "../collections/notebooks";
|
2020-02-06 16:46:23 +05:00
|
|
|
import Trash from "../collections/trash";
|
2020-02-21 21:39:27 +05:00
|
|
|
import Tags from "../collections/tags";
|
2020-02-11 13:12:47 +05:00
|
|
|
import User from "../models/user";
|
2020-02-11 16:28:28 +05:00
|
|
|
import Sync from "./sync";
|
2020-03-07 12:29:55 +05:00
|
|
|
import Vault from "./vault";
|
2020-03-09 12:39:49 +05:00
|
|
|
import Lookup from "./lookup";
|
2020-03-19 11:30:05 +05:00
|
|
|
import Content from "../collections/content";
|
2020-04-04 13:34:17 +05:00
|
|
|
import Conflicts from "./conflicts";
|
2020-02-03 12:03:07 +05:00
|
|
|
|
2020-02-11 13:12:47 +05:00
|
|
|
class Database {
|
2020-02-03 12:03:07 +05:00
|
|
|
constructor(context) {
|
2020-04-13 12:46:29 +05:00
|
|
|
this.context = new Storage(context);
|
2020-02-03 12:03:07 +05:00
|
|
|
}
|
2020-04-15 23:25:53 +05:00
|
|
|
|
2020-02-03 12:03:07 +05:00
|
|
|
async init() {
|
2020-04-15 23:25:53 +05:00
|
|
|
this.notes = await Notes.new(this);
|
2020-04-15 23:45:56 +05:00
|
|
|
this.notebooks = await Notebooks.new(this);
|
2020-04-15 23:25:53 +05:00
|
|
|
/* this.notebooks = new Notebooks(this.context);
|
2020-02-05 00:17:12 +05:00
|
|
|
this.notes = new Notes(this.context);
|
2020-02-06 16:46:23 +05:00
|
|
|
this.trash = new Trash(this.context);
|
2020-02-11 13:12:47 +05:00
|
|
|
this.user = new User(this.context);
|
2020-02-21 21:39:27 +05:00
|
|
|
this.tags = new Tags(this.context, "tags");
|
|
|
|
|
this.colors = new Tags(this.context, "colors");
|
2020-03-19 11:30:05 +05:00
|
|
|
this.delta = new Content(this.context, "delta");
|
|
|
|
|
this.text = new Content(this.context, "text");
|
|
|
|
|
await this.delta.init();
|
|
|
|
|
await this.text.init();
|
2020-02-21 21:39:27 +05:00
|
|
|
await this.tags.init();
|
|
|
|
|
await this.colors.init();
|
2020-03-19 11:30:05 +05:00
|
|
|
await this.notes.init(
|
|
|
|
|
this.notebooks,
|
|
|
|
|
this.trash,
|
|
|
|
|
this.tags,
|
|
|
|
|
this.colors,
|
|
|
|
|
this.delta,
|
|
|
|
|
this.text
|
|
|
|
|
);
|
2020-02-21 22:06:13 +05:00
|
|
|
await this.notebooks.init(this.notes, this.trash);
|
2020-03-21 11:15:24 +05:00
|
|
|
await this.trash.init(this.notes, this.notebooks, this.delta, this.text);
|
2020-02-11 16:28:28 +05:00
|
|
|
this.syncer = new Sync(this);
|
2020-03-07 12:29:55 +05:00
|
|
|
this.vault = new Vault(this, this.context);
|
2020-04-04 13:29:33 +05:00
|
|
|
this.conflicts = new Conflicts(this);
|
2020-04-15 23:25:53 +05:00
|
|
|
this.lookup = new Lookup(this); */
|
2020-02-11 16:28:28 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sync() {
|
|
|
|
|
return this.syncer.start();
|
2020-02-03 12:03:07 +05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-11 13:12:47 +05:00
|
|
|
export default Database;
|