<commit_before>## 04 - Relations and connections
Before we start, lets setup 2 schemas..

```js
// People.js
import mongoose from 'mongoose';
import composeWithMongoose from 'graphql-compose-mongoose';

var PeopleSchema = new mongoose.Schema({
  firstName: { type: String },
  lastName: { type: String },
  email: { type: String },
  jobId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Company'
  }
});

export const People = mongoose.model('People', PeopleSchema);
export const PeopleTC = composeWithMongoose(People);
```

```js
// Company.js
import mongoose from 'mongoose';
import composeWithMongoose from 'graphql-compose-mongoose';

var CompanySchema = new mongoose.Schema({
  name: { type: String },
  description: { type: String },
  employeeIds: [{
    type: mongoose.Schema.Types.ObjectId,
    ref: 'People'
  }],
});
export const Company = mongoose.model('Company', CompanySchema);
export const CompanyTC = composeWithMongoose(Company);
```

### Adding a single relation
Lets start of building a relation from the people to their jobs.

```js<commit_msg>docs: remove `ref` from example, cause it do not used by gql-mongoose<commit_after>## 04 - Relations and connections
Before we start, lets setup 2 schemas..

```js
// People.js
import mongoose from 'mongoose';
import composeWithMongoose from 'graphql-compose-mongoose';

var PeopleSchema = new mongoose.Schema({
  firstName: { type: String },
  lastName: { type: String },
  email: { type: String },
  jobId: {
    type: mongoose.Schema.Types.ObjectId,
  }
});

export const People = mongoose.model('People', PeopleSchema);
export const PeopleTC = composeWithMongoose(People);
```

```js
// Company.js
import mongoose from 'mongoose';
import composeWithMongoose from 'graphql-compose-mongoose';

var CompanySchema = new mongoose.Schema({
  name: { type: String },
  description: { type: String },
  employeeIds: [{
    type: mongoose.Schema.Types.ObjectId,
  }],
});
export const Company = mongoose.model('Company', CompanySchema);
export const CompanyTC = composeWithMongoose(Company);
```

### Adding a single relation
Lets start of building a relation from the people to their jobs.

```js
{'fraction_non_alphanumeric': 0.12702078521939955, 'fraction_numerical': 0.002771362586605081, 'mean_word_length': 4.625974025974026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '749915', 'n_tokens_mistral': 678, 'n_tokens_neox': 674, 'n_words': 206}