by oneearedrabbit · 3y ago · 0 comments
User::Account.server(database: "tmp/test.sqlite").first.
folders_dataset.offset(1).first
notes.
map(&:attachments).flatten.
find { |el| el.is_a?(User::ObjectTypes::EmbeddedPublicJpeg) &&
el.height > 700 &&
el.summary[/animal/i] }.
media_filepath
=> "Accounts/<uuid>/Media/F669B83A-0C47-408E-9645-015737F3B11F/Pasted Graphic.jpg"
Apple Notes' database structure is a fascinating product story. Notes started as a simple note-taking application that stored its content as raw HTML in a few simple tables. However, as the product grew and needed more features like collaboration, they had to make changes and add new columns and tables. They also implemented two flavors of CRDT-like algorithms that evolved over time: one for plaintext chunks and the other one for embedded objects like tables. On top of that, every change that Apple makes must be backward compatible to support legacy devices and systems; but backward-compatibility was not always possible and users had to go through “Migrate your Notes” steps, but it is again a product story.I wish that one day, someone from the development team would write an article about it.
[0] https://devlog.notespub.com/2022/08/site-generator-for-apple...
It looked like the other stuff came later and was somewhat orthogonal. (Although their ordered set construct was abusing topotext to represent ordered lists of ids.)
I don't know how much has changed since 2018. I think my table decoding may be broken now.
At some point, I also had some issues syncing notes between different iCloud accounts when the folder had 100s of notes, and that was probably the tipping point. As I was struggling to make it work, I kept thinking that if I just had a bunch of Markdown files I could move around, the whole process would have been easier.
I eventually realized I didn't need most features of Apple Notes, and moved to Obsidian[1]. It feels quite snappy too, and now I can easily publish some of my notes. It can also use iCloud Drive for syncing between Apple devices. It's missing some collaborative features, but I also didn't need those.
[0]: https://ricardoanderegg.com/posts/apple-notes-blog-cms/ [1]: https://ricardoanderegg.com/posts/apple-notes-to-obsidian/
I am sure that Apple won’t be making any substation breaking changes to a database structure unless they have to, there is a price to pay. Such changes will always be tied to a major macOS/iPhone release, and it doesn't happen very often.
That said, I had to put this project on the back burner, it was not immediately clear what is the ROI especially considering there is a long tail of databases to parse. It starts with Mountain Lion and then adds up quickly.
I need to release my source code to Github--ORM approach was worth exploring, it is a concise declaration that is relatively easy to update and manage.
I was planning on looking into support Samsung notes and Apple notes next. An open-source project like in the OP will help a lot here!
You can subscribe to a newsletter here if you're interested (in the top right of the page)
https://streamsoft.gumroad.com/l/remarkable-to-obsidian?layo...
I do whish the standard software made more concessions to third party software - ssh access is great, but running any kind of gui app feels hacky.