cfg_common.js 773 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Created by Tony on 2017/6/6.
  3. */
  4. class cfgCommon{
  5. constructor(modelObj) {
  6. this.modelObj = modelObj;
  7. }
  8. get(id, callback){
  9. this.modelObj.find({ID: id}, '-_id', function(err, templates){
  10. if(templates.length){
  11. callback(false, templates[0]);
  12. }
  13. else{
  14. callback('no record was found!');
  15. }
  16. })
  17. };
  18. getAll(id, callback){
  19. this.modelObj.find({}, '-_id', function(err, templates){
  20. if(templates.length){
  21. callback(false, templates);
  22. }
  23. else{
  24. callback('no record was found!');
  25. }
  26. })
  27. };
  28. };
  29. //module.exports = new cfgCommon(null);
  30. module.exports = cfgCommon;