Introduction
Introduction
In the realm of Empress, a DocType stands as a pivotal component in any application built on the Empress Framework. When it comes to the Model-View-Controller (MVC) paradigm, the DocType delineates both the Model and the View of your data. It embodies the fields of your data, their interactions, and the naming conventions of your data. Furthermore, it facilitates a robust Object Relational Mapper (ORM) pattern, which will be elaborated on later in this guide.
In layman’s terms, an ORM provides a convenient method to read, write, and update data in a database, eliminating the need for explicit SQL statements.
Conventions
To accelerate application development, the Empress Framework adheres to certain standard conventions:
- A DocType is always singular. For instance, if you’re storing a list of articles in the database, the doctype should be named Article.
- Table names are prefixed with
tab
. Hence, the table name for Article doctype becomestabArticle
.
Creating a DocType is straightforward. Simply type new doctype in the search bar located in the Desk.
frappe.get_doc({
"doctype": "Article",
...
})
A DocType doesn’t just store fields; it also retains information about how your data interacts within the system, a concept known as Meta. Since this meta-data is stored in a database table, it can be altered on-the-fly with minimal code.
frappe.get_meta('Article')
After creating a DocType, Empress instantly provides a host of features. For example, navigating to /app/todo
will lead you to the List View in the desk.
frappe.get_list("Article")
Likewise, the Form View, which is used to create new docs and view them, can be accessed at /app/todo/000001
.
frappe.get_doc('Article', '000001')
Conclusion
In the context of business solutions development and customization, the DocType feature is invaluable. It not only simplifies data modeling and view rendering but also enhances data management with its in-built ORM. Whether you’re designing an application’s data structure or managing data interactions in the system, the DocType in Empress has got you covered.