Navigation Menu

Skip to content

Commit

Permalink
Prepare method to create new domain ID
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Aug 2, 2012
1 parent 995f888 commit 8341825
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/database/domain.js
Expand Up @@ -68,13 +68,13 @@ Domain.prototype = {
initializeNameAndId: function(source) {
if (typeof source == 'string') {
this.name = source;
this.id = this.getIdFromTable(this.toTableNamePart(this.name));
this.id = this.getIdForTable(this.toTableNamePart(this.name));
return;
}

if (source.query && source.query.DomainName) {
this.name = source.query.DomainName;
this.id = this.getIdFromTable(this.toTableNamePart(this.name));
this.id = this.getIdForTable(this.toTableNamePart(this.name));
return;
}

Expand All @@ -99,7 +99,7 @@ Domain.prototype = {

throw new Error('no domain name');
},
getIdFromTable: function(tableName) {
getIdForTable: function(tableName) {
if (this.context) {
var tables = this.context.tableListSync();
var tableIdMatcher = new RegExp('^' + tableName + '_([^_]+)$');
Expand All @@ -114,7 +114,10 @@ Domain.prototype = {
}, this))
return id;
}
return this.id;
return this.createNewId();
},
createNewId: function() {
// we must calculate it!
},

get tableName() {
Expand Down Expand Up @@ -160,7 +163,7 @@ Domain.prototype = {
},

get id() {
return this._id || DEFAULT_DOMAIN_ID;
return this._id === undefined ? DEFAULT_DOMAIN_ID : this._id ;
},
set id(value) {
return this._id = value;
Expand Down

0 comments on commit 8341825

Please sign in to comment.