dayzNnitez
dayzNnitez

Reputation: 1

Simple friendship relationship between users in mongoose

Hi could someone explain to me how I would write a simple friendship relationship in mongoose

var mongoose = require('mongoose'),
Schema = mongoose.Schema;

var User = new Schema({

username:{
    type: String,
    unique: true,
    required: true
},
password:{
    type: String,
    required: true
},
friends:{[

    // stuck here How would i define what another user is here
]}
}

});

Upvotes: 0

Views: 531

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191789

friends: [{type: Schema.ObjectId, ref: "User"}]

Upvotes: 2

Related Questions