Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. const mongoose = require('mongoose');
  2.  
  3. // Book Schema
  4. const userSchema = mongoose.Schema({
  5. name:{
  6. type: String,
  7. required: true
  8. },
  9. email:{
  10. type: String,
  11. required: true
  12. },
  13. password:{
  14. type: String,
  15. hidden: true
  16. },
  17. create_date:{
  18. type: Date,
  19. default: Date.now
  20. }
  21. });
  22.  
  23.  
  24. const User = module.exports = mongoose.model('User', genreSchema);+
  25.  
  26. module.exports.getUsers = (callback, limit) => {
  27. User.find(callback).limit(limit);
  28. }
  29.  
  30. // Add user
  31. module.exports.addGenre = (genre, callback) => {
  32. User.create(genre, callback);
  33. }
  34.  
  35. // Update user
  36. module.exports.updateGenre = (id, genre, options, callback) => {
  37. var query = {_id: id};
  38. var update = {
  39. name: user.name,
  40. }
  41. User.findOneAndUpdate(query, update, options, callback);
  42. }
  43.  
  44. // Delete user
  45. module.exports.removeGenre = (id, callback) => {
  46. var query = {_id: id};
  47. User.remove(query, callback);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement