title: How to store objectIDs of other collection inside an array using mongoose schema?
body: <p>I have two collections where one holds list of systems and the other holds list of battery attached to the system. I want to store an array of ObjectIDs of batteries inside a document so that I can populate it later. Also how will I structure my post request in postman?</p>
  <pre><code>const mongoose = require('mongoose');
  
  const { Schema } = mongoose;
  
  const SystemSchema = new Schema(
    {
      serialNumber: String,
      location: String,
      BPIDs: [
        {
          type: Schema.Types.ObjectId,
          ref: 'batteryPack'
        }
      ]
    },
    {
      timestamps: true
    }
  );
  
  const Systems = mongoose.model('system', SystemSchema);
  
  module.exports = Systems;
  </code></pre>
  <p>My battery model is as follows:</p>
  <pre><code>const mongoose = require('mongoose');
  
  const { Schema } = mongoose;
  
  const batteryPackSchema = new Schema(
    {
      systemSerialNumber: String,
      batteryID: Number,
      batteryVoltage: Number,
      totalCurrent: Number,
      stateOfCharge: Number
    {
      timestamps: true
    }
  );
  
  const BatteryPacks = mongoose.model('batteryPack', batteryPackSchema);
  
  module.exports = BatteryPacks;
  </code></pre>
  <p>My add route is as follows:</p>
  <pre><code>const addDevice = async systemData =&gt; {
    try {
      const { serialNumber, location, BPIDs } = systemData;
      const createDevice = new Systems({
        serialNumber,
        location,
        BPIDs
      });
      await createDevice.save();
      return {
        status: 200,
        message: 'System added successfully!'
      };
    } catch (error) {
      console.error(error);
    }
  };
  </code></pre>