nodejs: How generate schema.pre('save',...) unique field

I have user registration on mongoose and I need to generate unique random ident field from possible values. The problem is I can not query to mongodb.

The result of script in console is "ONE". That's it. So, where is mistake? And is there better way to generate unique random field/number?

schemaUser.pre('save', function (next) {

    var self = this;

    function genIdent() {
        var ident = "", possible = "013456789";

        for(var i=1; i <= 5; i++)
            ident += possible.charAt(Math.floor(Math.random() * possible.length));

        return ident;
    }

    function doIt() {
        var ident = genIdent();

        console.log('ONE');

        mongoose.model('User', schemaUser).findOne({ident: ident}, function(err, o) {
            console.log('TWO');
            if (o) {
                doIt();
            } else {
                self.ident = ident;
                next();
            }
        });

    }

    doIt();

});

it looks like you are just generating ident, but not putting it into your MongoDB, and trying to find it in there before you save it in there...

to be able to access a document with that ident you need to save it first.

try putting console.log(err) to see what error is returned