Notes - SankethBK/diaryvault GitHub Wiki
Notes folder has the logic for CRUD operations for notes. FlutterQuill is used as rich text editor.
This is the schema of the notes entity:
Notes {
final String id;
final DateTime createdAt;
final String title;
final String body;
final String hash;
final DateTime lastModified;
final String plainText;
final List<NoteAsset> assetDependencies;
final bool deleted;
final String? authorId;
}
- id: An UUID will be generated when a new note is created. It will be used as unique identifier for a note. After cloud-sync ID of a note will remain same across multiple devices.
- createdAt: Indicates the timestamp at which note was created. Can be set by user during note-creation. Its shown in home page and read-only page.
- title: Title of note.
- body: Output of FlutterQuill's controller stored in the form of JSON. Indicates the contents of rich-text editor.
- hash: The hash value is SHA1 hash of note's title + note's body + note's created_at timestamp. This hash serves as a digital fingerprint, if either note's title, body or created_at changes, then note's SHA1 hash changes and it will be synced to cloud.
- lastModified: Will hold the last modified timestamp of a note. Is used during cloud-syncup to determine which copy of note is newest.
- plainText: All contents of rich-text editor are also stored as plain text. Is used for search functionality.
-
assetDependencies: Holds details of external assets associated with a note, like images and videos. We store the path names of each external assets in
Note_dependencies
table, as we also need to sync external assets during cloud-syncup. -
deleted: Will indicate if a note is deleted. When user deletes a note, all external assets, title and body of a note are set to
null
or empty text and deleted is set totrue
. Because we also need to delete that note in cloud. - authorId: Stores the user ID generated by firebase. In case multiple accounts are registered on same device, it will be used to isolate the notes of one user from another.