Description
Problem Statement
Currently, our SDK handles messages and POSTs without utilizing an Object-Relational Mapping (ORM) approach. While this method is functional, it lacks some of the user-friendly, dynamic features that an ORM could provide.
Motivation
An ORM layer would make it easier for developers to interact with POSTs, particularly when it comes to unique functionalities like amendments and revisions. It could also pave the way for more advanced features without adding complexity to the API. The feature is already effectively implemented in the Active Record SDK and can offer insights into implementation here.
Proposed Solution
Integrate an ORM layer into the SDK for handling POSTs:
- Offer a simplified syntax for operations like create, read, update, and delete (CRUD).
- Provide an easy way to navigate through past revisions of a POST.
- Allow dynamic amendments to POSTs, making the system more adaptable.
Example Use-Case
A developer wants to amend a POST. Instead of navigating through complex APIs or writing cumbersome code, they could simply execute something like:
post = await Post.find(item_hash) # can fetch directly through HTTPS or from local cache
post.content = { "foo": "bar" }
await post.save() # Post is now being amended
This automatically handles amendments and keeps track of past revisions.
Additional Context: Program/Instance Messages
Additionally, building on this, we can also introduce ORM behavior for PROGRAM
and INSTANCE
messages. There, we could directly integrate all the actions a user can execute on such VMs:
instance = Instance.find(item_hash)
if instance.errors:
await instance.restart() # trigger a restart