# Copyright (c) 2015, InfluxFramework LLC
# License: MIT. See LICENSE
import influxframework


def add_custom_field(doctype, fieldname, fieldtype="Data", options=None):
	influxframework.get_doc(
		{
			"doctype": "Custom Field",
			"dt": doctype,
			"fieldname": fieldname,
			"fieldtype": fieldtype,
			"options": options,
		}
	).insert()


def clear_custom_fields(doctype):
	influxframework.db.delete("Custom Field", {"dt": doctype})
	influxframework.clear_cache(doctype=doctype)
