-
-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mongo): support user and password connection options
- Loading branch information
Showing
2 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { ObjectID } from 'mongodb'; | ||
import { Collection, EntityManager, MikroORM, QueryOrder } from '../lib'; | ||
import { Collection, Configuration, EntityManager, MikroORM, QueryOrder } from '../lib'; | ||
import { EntityProperty } from '../lib/decorators'; | ||
import { Author, Book, BookTag, Publisher, PublisherType, Test } from './entities'; | ||
import { AuthorRepository } from './repositories/AuthorRepository'; | ||
import { initORM, wipeDatabase } from './bootstrap'; | ||
import { MongoDriver } from '../lib/drivers/MongoDriver'; | ||
import { MongoConnection } from '../lib/connections/MongoConnection'; | ||
import { Logger } from '../lib/utils'; | ||
|
||
/** | ||
|
@@ -307,6 +308,15 @@ describe('EntityManagerMongo', () => { | |
await expect(driver.getConnection().execute('')).rejects.toThrowError('MongoConnection does not support generic execute method'); | ||
}); | ||
|
||
test('should use user and password as connection options', async () => { | ||
const config = new Configuration({ user: 'usr', password: 'pw' } as any, false); | ||
const connection = new MongoConnection(config); | ||
await expect(connection.getConnectionOptions()).toEqual({ | ||
useNewUrlParser: true, | ||
auth: { user: 'usr', password: 'pw' }, | ||
}); | ||
}); | ||
|
||
test('findOne by id', async () => { | ||
const authorRepository = orm.em.getRepository(Author); | ||
const jon = new Author('Jon Snow', '[email protected]'); | ||
|