Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. var mongoose = require('mongoose');
  2. var findOrCreate = require('mongoose-findorcreate');
  3.  
  4. // Create a connect.js inside the models/ directory that
  5. // exports your MongoDB URI!
  6. var connect = process.env.MONGODB_URI || require('./connect');
  7.  
  8. // If you're getting an error here, it's probably because
  9. // your connect string is not defined or incorrect.
  10. mongoose.connect(connect);
  11.  
  12. // Step 1: Write your schemas here!
  13. // Remember: schemas are like your blueprint, and models
  14. // are like your building!
  15. var contactSchema = mongoose.Schema({
  16. name: String,
  17. phone: String,
  18. owner: String
  19. });
  20.  
  21. var userSchema = mongoose.Schema({
  22. username: String,
  23. password: String,
  24. phone: String,
  25. facebookId: String,
  26. facebookToken: String,
  27. pictureURL: String,
  28. friends: Object,
  29. twitterId: String,
  30. twitterToken: String,
  31. twitterTokenSecret: String,
  32. followers: Object
  33. });
  34. userSchema.plugin(findOrCreate);
  35.  
  36. var messageSchema = mongoose.Schema({
  37. created: Date,
  38. content: String,
  39. user: String,
  40. contact: String,
  41. channel: String,
  42. status: String,
  43. from: String
  44. });
  45.  
  46. // Step 2: Create all of your models here, as properties.
  47. var models = {
  48. Contact: mongoose.model('Contact', contactSchema),
  49. User: mongoose.model('User', userSchema),
  50. Message: mongoose.model('Message', messageSchema)
  51. };
  52.  
  53. // Step 3: Export your models object
  54. module.exports = models;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement