lib/ohm/lua/delete.lua in ohm-2.0.0.alpha3 vs lib/ohm/lua/delete.lua in ohm-2.0.0.alpha4
- old
+ new
@@ -1,7 +1,28 @@
-local model = cmsgpack.unpack(ARGV[1])
-local uniques = cmsgpack.unpack(ARGV[2])
-local tracked = cmsgpack.unpack(ARGV[3])
+-- This script receives three parameters, all encoded with
+-- MessagePack. The decoded values are used for deleting a model
+-- instance in Redis and removing any reference to it in sets
+-- (indices) and hashes (unique indices).
+--
+-- # model
+--
+-- Table with three attributes:
+-- id (model instance id)
+-- key (hash where the attributes will be saved)
+-- name (model name)
+--
+-- # uniques
+--
+-- Fields and values to be removed from the unique indices.
+--
+-- # tracked
+--
+-- Keys that share the lifecycle of this model instance, that
+-- should be removed as this object is deleted.
+--
+local model = cmsgpack.unpack(ARGV[1])
+local uniques = cmsgpack.unpack(ARGV[2])
+local tracked = cmsgpack.unpack(ARGV[3])
local function remove_indices(model)
local memo = model.key .. ":_indices"
local existing = redis.call("SMEMBERS", memo)