swagelize
Version:
Generate Sequelize model definitions and DAO from a Swagger 2.0 schema
90 lines (80 loc) • 1.81 kB
JavaScript
const models = require('../models');
const Op = models.Sequelize.Op;
exports.createUser = function(body) {
return models.User.create({
//attribute1: valueAttribute1,
//attribute2: valueAttribute2,
});
};
exports.createUsersWithArrayInput = function(body) {
return models.User.create({
//attribute1: valueAttribute1,
//attribute2: valueAttribute2,
});
};
exports.createUsersWithListInput = function(body) {
return models.User.create({
//attribute1: valueAttribute1,
//attribute2: valueAttribute2,
});
};
exports.loginUser = function(username, password) {
return models.User.find({ // TODO PLEASE SET THE DESIRED METHOD HERE
include: [
//{
//model: models.<<MODEL TO BE INCLUDED>>,
//attributes: {exclude: [<<ATTRIBUTES TO BE EXCLUDED>>]}
//}
],
where: {
//<<ATTRIBUTE>>: <<PARAM>>,
//<<ANOTHER_ATTRIBUTE>>: <<ANOTHER_PARAM>>
}
});
};
exports.logoutUser = function() {
return models.User.find({
include: [
//{
//model: models.<<MODEL TO BE INCLUDED>>,
//attributes: {exclude: [<<ATTRIBUTES TO BE EXCLUDED>>]}
//}
],
where: {
//<<ATTRIBUTE>>: <<PARAM>>,
//<<ANOTHER_ATTRIBUTE>>: <<ANOTHER_PARAM>>
}
});
};
exports.getUserByName = function(username) {
return models.User.find({
include: [
//{
//model: models.<<MODEL TO BE INCLUDED>>,
//attributes: {exclude: [<<ATTRIBUTES TO BE EXCLUDED>>]}
//}
],
where: {
//<<ATTRIBUTE>>: <<PARAM>>,
//<<ANOTHER_ATTRIBUTE>>: <<ANOTHER_PARAM>>
}
});
};
exports.updateUser = function(username, body) {
return models.User.update({
//attribute1: valueAttribute1,
//attribute2: valueAttribute2,
},
{
where: {
//id: idValue
}
});
};
exports.deleteUser = function(username) {
return models.User.destroy({
where: {
//id: valueId,
}
});
};