summaryrefslogtreecommitdiffstats
path: root/acf2/model/node.lua
diff options
context:
space:
mode:
Diffstat (limited to 'acf2/model/node.lua')
-rw-r--r--acf2/model/node.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/acf2/model/node.lua b/acf2/model/node.lua
index 86722f2..02eb12f 100644
--- a/acf2/model/node.lua
+++ b/acf2/model/node.lua
@@ -62,6 +62,15 @@ function M.TreeNode:init(context)
mt.__eq = equal_tns
mt._meta = {}
function mt.get(k, options) return mt.load(k, options) end
+ function mt.removable() return true end
+
+ function mt.check_removable(k, v)
+ if v ~= nil then return end
+ local old = mt.load(k, {dereference=false})
+ if isinstance(old, M.TreeNode) and not getmetatable(old).removable() then
+ raise(pth.join(mt.path, k), 'Cannot be deleted')
+ end
+ end
if not mt.txn then return end
@@ -209,6 +218,7 @@ function M.Collection:init(context, params)
if not params.editable then
raise(mt.path, 'Collection is not editable')
end
+ mt.check_removable(k, v)
mt.member(k):save(v)
end
end