I have a company that contains products:
class Company
include Mongoid::Document
include Mongoid::Timestamps
embeds_many :products
index({"products.code" => 1}, {sparse: true, unique: true})
end
But when I create products(in the same parent) with the same code, like '123', the index does not check the uniqueness of it and it gets created normally. What is wrong?