function generate(count) {
var founded = false,
_sym = 'abcdefghijklmnopqrstuvwxyz1234567890',
str = '';
while(!founded) {
for(var i = 0; i < count; i++) {
str += _sym[parseInt(Math.random() * (_sym.length))];
}
base.getID(string, function(err, res) {
if(!res.length) {
founded = true; // How to do it?
}
});
}
return str;
}
Wie setze ich einen Variablenwert mit einem Datenbankabfrage-Rückruf? Wie kann ich es tun?
var hexstring = crypto.randomBytes(16).toString("hex");
var guidstring = hexstring.substring(0,8) + "-" + hexstring.substring(8,12) + "-" + hexstring.substring(12,16) + "-" + hexstring.substring(16,20) + "-" + hexstring.substring(20);
new mongo.ObjectID();
und manuell stackoverflow.com/a/56106999/4701635