# Problem with relationship on mongoose with multiple db setup

**URL:** <https://community.forestadmin.com/t/problem-with-relationship-on-mongoose-with-multiple-db-setup/5270>\
**Category:** Help me!\
**Created:** [September 20, 2022, 8:27am UTC](https://community.forestadmin.com/t/problem-with-relationship-on-mongoose-with-multiple-db-setup/5270 "2022-09-20T08:27:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LouisLoode](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louisloode/32/5960_2.png) [@LouisLoode](https://community.forestadmin.com/u/LouisLoode)\
**Post date:** [September 20, 2022, 8:27am UTC](https://community.forestadmin.com/t/problem-with-relationship-on-mongoose-with-multiple-db-setup/5270/1 "2022-09-20T08:27:20Z")

</div>

## Feature(s) impacted

Related collections

## Observed behavior

Hello i cannot create has many relationship like the documentation:

> **[Relationships | Developer Guide](https://docs.forestadmin.com/documentation/reference-guide/models/relationships)**

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”):

 ![Capture d’écran 2022-09-20 à 10.16.07](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/3df2d678dd7ce07bdfa362337be6d4fd58740d2f.png)

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

 ![Capture d’écran 2022-09-20 à 10.16.52](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/a/a3596550eb3867bbcd9e6da91cb1b85cfff62465.png)

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

 ![Capture d’écran 2022-09-20 à 10.25.22](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/60143c5171895dbbf3bf8b0e2cd5668508ccb85e.png)

## Context

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

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [September 21, 2022, 12:09pm UTC](https://community.forestadmin.com/t/problem-with-relationship-on-mongoose-with-multiple-db-setup/5270/2 "2022-09-21T12:09:58Z")

</div>

Hi @LouisLoode,

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

---

<div class="post-metadata">

**Author:** ![LouisLoode](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louisloode/32/5960_2.png) [@LouisLoode](https://community.forestadmin.com/u/LouisLoode)\
**Post date:** [September 21, 2022, 1:20pm UTC](https://community.forestadmin.com/t/problem-with-relationship-on-mongoose-with-multiple-db-setup/5270/3 "2022-09-21T13:20:50Z")

</div>

Hey vince,  
This is my interconnections model:

```javascript
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models

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
  });

  schema.index(
    {
      slug: 1
    },
    { unique: true }
  );

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

```

That’s all the code of my relashionship
