Skip to content

Instantly share code, notes, and snippets.

@krlicmuhamed
Last active August 29, 2015 14:19
Show Gist options
  • Save krlicmuhamed/b0e40de6d536b1c447f9 to your computer and use it in GitHub Desktop.
Save krlicmuhamed/b0e40de6d536b1c447f9 to your computer and use it in GitHub Desktop.
"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;
};
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