title: Adding and using new database models with NextAuth
body: <p>I'm using <a href="https://next-auth.js.org/" rel="nofollow noreferrer">NextAuth</a> to create a web service and connected it to a MongoDB database. I'm now able to log in with Google Auth and the records are saving correctly to my database. I now need to add new models to my database and add to them via API routes.</p>
  <p>I followed <a href="https://next-auth.js.org/tutorials/typeorm-custom-models" rel="nofollow noreferrer">these instructions</a> to add a custom model <code>Test</code>.</p>
  <p><strong>Test.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>export default class Test {
    constructor(name) {
      if (name) {
        this.name = name;
      }
    }
  }
  
  export const TestSchema = {
    name: 'Test',
    target: Test,
    columns: {
      id: {
        // This property has `objectId: true` instead of `type: int` in MongoDB
        primary: true,
        type: 'int',
        generated: true,
      },
      name: {
        type: 'varchar',
        nullable: true,
      },
      createdAt: {
        type: 'timestamp',
        createDate: true,
      },
      updatedAt: {
        type: 'timestamp',
        updateDate: true,
      },
    },
  };
  </code></pre>
  <p><strong>index.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>import Test, { TestSchema } from './Test';
  
  export default {
    Test: {
      model: Test,
      schema: TestSchema,
    },
  };
  </code></pre>
  <p>The I updated <strong>[...nextauth.js]</strong> to add <code>Test</code> to my adapter</p>
  <pre class="lang-js prettyprint-override"><code>adapter: Adapters.TypeORM.Adapter(
    process.env.DATABASE_URL,
    {
      models: {
        Test: Models.Test,
      },
    }
  )
  </code></pre>
  <p>At this point I'm not seeing any errors but I'm not sure it's added correctly. So I want to try to create a test <code>Test</code> document. However, I can't find any documentation on <em>how</em> to do this. I need to have access to the database connection but I've tried logging everything imported from  'next-auth/adapters', 'next-auth/client', 'next-auth', req, etc. and can't find anywhere that this connection is stored. I'd think I need to call the <code>getAdapter()</code> function stored in the TypeORM Adapter class but I can't seem to access it. I also tried accessing any of the built in methods like <code>setUser</code> and can't get those either. So I can't find any way to manually modify database records.</p>