Created
August 13, 2016 15:33
-
-
Save suissa/792a39c96db630872d4a7c03410fa4f1 to your computer and use it in GitHub Desktop.
CRUD em cima do Model para se testar
This file contains hidden or 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'; | |
const Model = require('./model'); | |
const CRUD = { | |
create: function(data,callback) { | |
const model = new Model(data); | |
model.save(callback); | |
}, | |
retrieve: function(query,callback) { | |
Model.find(query,callback); | |
}, | |
update: function(query, mod, options) { | |
options = options || {}; | |
Model.update(query, mod, options, function (err, data) { | |
if (err) { | |
return console.log('ERRO: ', err); | |
} | |
return console.log('Alterou:', data); | |
}); | |
}, | |
delete: function(query) { | |
Model.remove(query, function (err, data) { | |
if (err) { | |
return console.log('ERRO: ', err); | |
} | |
return console.log('Deletou:', data); | |
}); | |
}, | |
}; | |
module.exports = CRUD; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment