skip to Main Content

Mongodb – Trying to populate blogs in user but not working – mongoose

user.ts import mongoose from "mongoose"; const UserSchema=new mongoose.Schema({ _id:mongoose.Types.ObjectId, name:{ type:String, require:true }, email:{ type:String, require:true }, password:{ type:String, require:true, }, liked:[{ type: mongoose.Types.ObjectId, ref:'blogs', require:true }], myBlog:[{ type: mongoose.Types.ObjectId, ref:'blogs', require:true }] }) module.exports=mongoose.models.users||mongoose.model('users',UserSchema) blogs.ts import mongoose from "mongoose";…

VIEW QUESTION

atlas .find returning empty array while local mongodb works fine

no errors console logs [] const mongoose = require('mongoose'); const uri = "mongodb+srv://:@cluster0.yhy4bwu.mongodb.net/?retryWrites=true&w=majority"; const playerSchema = new mongoose.Schema({ fullname: String, goals: Number, assists: Number, gamesPlayed: String, shots: Number, positionCode: String, plusminus: String, team: String, timeOnIcePerGame: Number, espnId: Number }) mongoose.connect(uri)…

VIEW QUESTION

Mongodb – How to add conditions inside $lte?

I have a collection: @Prop({ type: Number, required: true, default: 0 }) have:number; @Prop({ type: Boolean, required: false, default: null }) unstable?: boolean; @Prop({ type: Number, required: false, default: null }) max?: number; I need to filter the selection according…

VIEW QUESTION
Back To Top
Search