If you have a field called slug and you make it unique but also autogenerate it using following scripts, then it won’t check the uniqueness. Duplicate slug saved even though unique constraint is applied in schema def.
var data = ctx.data;
if (data.title && data.title.iv) {
data.slug = { iv: slugify(data.title.iv) };
replace(data);
}