Navigation Menu

Skip to content

Commit

Permalink
Generate random ID
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 2, 2012
1 parent 66ecdb5 commit b4f945e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/database/domain.js
Expand Up @@ -117,7 +117,14 @@ Domain.prototype = {
return this.createNewId();
},
createNewId: function() {
// we must calculate it!
var size = 26;
var characters = '0123456789abcdefghijklmnopqrstuvwxyz'.split('');
var lastIndex = characters.length;
var id = '';
while (id.length < size) {
id += characters[Math.round(Math.random() * lastIndex)];
}
return id;
},

get tableName() {
Expand Down

0 comments on commit b4f945e

Please sign in to comment.