Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
quiero comprobar si el usuario actual está siguiendo a otro usuario

quiero verificar si el usuario actual está siguiendo otro uso, digamos verificar si el usuario A está siguiendo al usuario B.

Modelo de usuario: -

 const UserSchema = new Schema({ email: { required: true, type: String, unique: true, lowercase: true, validate: (value) => { if (!validator.isEmail(value)) { throw new Error('Invalid email address.'); } } }, fullName: { required: true, type: String, }, username: { required: true, type: String, unique: true, lowercase: true, minlength: 3, }, password: { type: String, minlength: 8, }, avatar: String, bio: { type: String, default: null, maxlength:300, }, location: { type: String, default: 'Bangalore' }, website: { type: String, default: null, }, joindate: { type: Date, default: new Date() }, isVerified:{ type:Boolean, default:false, } }) const UserModel = mongoose.model('User', UserSchema); module.exports = UserModel;

Siguiente modelo:-

 const FollowingsSchema = new Schema({ user: { ref: 'User', unique:true, type: Schema.Types.ObjectId, }, followings: [{ user: { type: Schema.Types.ObjectId, ref: 'User' } }] }) const Followings = mongoose.model('Followings', FollowingsSchema); module.exports = Followings;

Modelo de seguidores: -

 const FollowersSchema = new Schema({ user: { ref: 'User', unique:true, type: Schema.Types.ObjectId, }, followers: [{ user: { type: Schema.Types.ObjectId, ref: 'User' } }] }) const Followers = mongoose.model('Followers', FollowersSchema); module.exports = Followers;

actualmente pude lograr esto iterando a través de cada seguidor y verificando si el usuario existe en esa lista de seguidores de usuarios. quiero lograr esto con la agregación mongodb, soy nuevo en mongob

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!