Last active
August 29, 2015 14:19
-
-
Save krlicmuhamed/b0e40de6d536b1c447f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
module.exports = function(sequelize, DataTypes) { | |
var computers = sequelize.define("computers", { | |
domain: DataTypes.STRING | |
}, { | |
classMethods: { | |
exists: function(d){ | |
return computers.count({where:{domain:d}}).then(function(count){ | |
if(count>0){ | |
return true; | |
}else{ | |
return false; | |
} | |
}); | |
} | |
}, | |
instanceMethods:{ | |
} | |
}); | |
return computers; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require("assert"); | |
var models = require('../models'); | |
describe('on computers model call', function(){ | |
describe('#exists(d)', function(){ | |
it('should return true if computer exists else return false', function(done){ | |
models.computers.exists('test').then(function(exists){ | |
console.log(exists); | |
assert.equal(true, exists); | |
done(); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment