Help with nodejs/express/mongodb issue

Hello, I’m a kind of newbie in nodejs. I’m working on the backend of a trivia game. I’m currently working on creating a live game API. In my livegame schema/model, I have a field called questions which is an array(for now its empty) of questions. Now when I create this api, I want to fetch questions from my questions model(yes I have created a model for questions) and push it into this questions array(in the livegame model/collection). How do i go about this pls?
This is my livegame schema:
const livegameSchema = new mongoose.Schema({

categoryName: { 

    type: String,

    required: [true, 'A live game must have a category name'],

    unique: true

},

gameTime: { 

    type: Number,

    required: true

},

entryFee: { 

    type: Number,

    required: true

},

participants: [

    {

        type: mongoose.Schema.ObjectId,

        ref: 'User'

    }

],

activeParticipants: [

    {

        type: mongoose.Schema.ObjectId,

        ref: 'User'

    }

],

questions: [

    {

        type: mongoose.Schema.ObjectId,

        ref: 'Question',

        required: [true, 'A live game must have questions']

    }

],

reward: {

    type: Number,

    required: true

},

status: {

    type: Boolean,

    default: true

},

shares: [

    {

        type: mongoose.Schema.ObjectId,

        ref: 'User'

    }

],

currentQuestion: {

    type: Number,

    default: 0

},

questionsTimer: {

    type: Number,

    default: 0

},

});

Hi @Adetunji and welcome to the cmmunity :wave:

It seems that at the moment there is noone in here who is knowledgeable about these topics. If you are still looking for help maybe try the MongoDB Forums

Or ask on Stack Overflow

I’m sorry that I can’t help you more :slightly_frowning_face:
Michael

1 Like