Problem with relationship on mongoose with multiple db setup

Feature(s) impacted

Related collections

Observed behavior

Hello i cannot create has many relationship like the documentation:

My collections are on differents databases, i test many things.

Expected behavior

Expected that it works like the documentation ?

Failure Logs

If the reference on model is “contracts” (my model “contracts” exists and use a collection “contracts” in a database “contracts”):

I test with a ref to “contracts.contracts”:

I check if the contract model is loaded before the model which use the “contracts” model, it’s ok (my model is “interconnections”):


  • Project name: Intent
  • Team name: Intent
  • Environment name: Development
  • Agent type & version: “forest-express-mongoose”: “^8.7.7”,

Thanks for your help :slight_smile:

Hi @LouisLoode,

Could you please show me how you did that relationship between those 2 databases please :pray: ?

Hey vince,
This is my interconnections model:

// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here:

module.exports = (mongoose, Mongoose) => {
  // This section contains the properties of your model, mapped to your collection's properties.
  const schema = Mongoose.Schema({
    contacts: {
      type: String
    slug: {
      type: String,
      require: true
    tickets: {
      type: [String]
    contracts: [{ type: Mongoose.Schema.Types.ObjectId, ref: 'contracts' }]
  }, {
    timestamps: { createdAt: 'creationDate', updatedAt: 'lastUpdateDate' },
    versionKey: false // You should be aware of the outcome after set to false

      slug: 1
    { unique: true }

  return mongoose.model('interconnections', schema, 'interconnections');

That’s all the code of my relashionship