Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UserProfile
- var UserSchema = new mongoose.Schema({
- userId:{ type: mongoose.Schema.Types.ObjectId, ref: "User" },
- picture : String,
- telephone: {
- type: String,
- unique: false
- },
- adresse:String,
- loc: {
- type: [Number], // [<longitude>, <latitude>]
- index: "2d" // create the geospatial index
- },
- metier:String,
- pays:String,
- ville:String,
- code_postal:Number });
- var UserSchema = new mongoose.Schema({
- email: {
- type: String,
- unique: true,
- required: true,
- trim: true
- },
- password: {
- type: String,
- required: true,
- },
- passwordConf: {
- type: String,
- required: true,
- },
- picture : String,
- telephone: {
- type: String,
- unique: false
- },
- adresse:String,
- loc: {
- type: [Number], // [<longitude>, <latitude>]
- index: "2d" // create the geospatial index
- },
- metier:String,
- pays:String,
- ville:String },{timestamps: true});
- User.aggregate([
- {
- $lookup:
- {
- from: "UserProfile",
- localField: "_id",
- foreignField: "userId",
- as: "profile"
- }
- }
- ], (err, user)=>{
- res.json({
- success: true,
- user : user
- });
- })
- {
- "success": true,
- "user": [
- {
- "_id": "5adcf607c187203e1c88d21e",
- "email": "userdemo@mail.com",
- "password": "demopass",
- "passwordConf": "demopass",
- "__v": 0,
- "profile": []
- },
- ....
Add Comment
Please, Sign In to add comment