daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Apr 27th, 2018 196 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // UserProfile
  2. var UserSchema = new mongoose.Schema({
  3. userId:{ type: mongoose.Schema.Types.ObjectId, ref: "User" },
  4. picture : String,
  5. telephone: {
  6.   type: String,
  7.   unique: false
  8. },
  9. adresse:String,
  10. loc: {
  11.   type: [Number], // [<longitude>, <latitude>]
  12.   index: "2d" // create the geospatial index
  13. },
  14. metier:String,
  15. pays:String,
  16. ville:String,
  17. code_postal:Number });
  18.    
  19. var UserSchema = new mongoose.Schema({
  20. email: {
  21.   type: String,
  22.   unique: true,
  23.   required: true,
  24.   trim: true
  25. },
  26. password: {
  27.   type: String,
  28.   required: true,
  29. },
  30. passwordConf: {
  31.   type: String,
  32.   required: true,
  33. },
  34. picture : String,
  35. telephone: {
  36.   type: String,
  37.   unique: false
  38. },
  39. adresse:String,
  40. loc: {
  41.   type: [Number], // [<longitude>, <latitude>]
  42.   index: "2d" // create the geospatial index
  43. },
  44. metier:String,
  45. pays:String,
  46. ville:String },{timestamps: true});
  47.    
  48. User.aggregate([
  49.   {
  50.      $lookup:
  51.      {
  52.         from: "UserProfile",
  53.         localField: "_id",
  54.         foreignField: "userId",
  55.         as: "profile"
  56.      }
  57.   }
  58. ], (err, user)=>{
  59.   res.json({
  60.      success: true,
  61.      user : user
  62.   });
  63. })
  64.    
  65. {
  66. "success": true,
  67. "user": [
  68.     {
  69.         "_id": "5adcf607c187203e1c88d21e",
  70.         "email": "userdemo@mail.com",
  71.         "password": "demopass",
  72.         "passwordConf": "demopass",
  73.         "__v": 0,
  74.         "profile": []
  75.     },
  76. ....
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top