function uniqueCode()
    {
        $i = 1;
        $codeFormat = 'code-%d';
        do {
            $code = sprintf($codeFormat, $i);
            $note = $this->findByCode($code);
            if (!$note) {
                return $code;
            }
            $i++;
        } while (true);
    }