2
0
mirror of https://github.com/frappe/books.git synced 2024-12-26 12:28:12 +00:00
books/docs/models/index.md
2018-02-22 13:07:50 +05:30

969 B

Declaring Models

Models are declared by adding a .js model file in the models/doctype folder of the module/app.

Note: A model is called DocType in Frappe.js

Fields

Every model must have a set of fields (these become database columns). All fields must have

  • fieldname: Column name in database / property name
  • fieldtype: Data type (see details)
  • label: Display label
  • required: Is mandatory
  • hidden: Is hidden
  • disabled: Is disabled

Example

module.exports = {
	"naming": "random",
	"name": "ToDo",
	"doctype": "DocType",
	"issingle": 0,
	"fields": [
		{
			"fieldname": "subject",
			"label": "Subject",
			"fieldtype": "Data",
			"reqd": 1
		},
		{
			"fieldname": "description",
			"label": "Description",
			"fieldtype": "Text"
		},
		{
			"fieldname": "status",
			"label": "Status",
			"fieldtype": "Select",
			"options": [
				"Open",
				"Closed"
			],
			"default": "Open",
			"reqd": 1
		}
	]
}