Skip to content

Commit cff3cfe

Browse files
committed
Add MongoClient creation to README, fixes #12
1 parent 155e50d commit cff3cfe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ This package uses [DataLoader](https://github.com/graphql/dataloader) for batchi
3434

3535
The basic setup is subclassing `MongoDataSource`, passing your collection or Mongoose model to the constructor, and using the [API methods](#API):
3636

37+
`data-sources/Users.js`
38+
3739
```js
3840
import { MongoDataSource } from 'apollo-datasource-mongodb'
3941

@@ -47,8 +49,13 @@ export default class Users extends MongoDataSource {
4749
and:
4850

4951
```js
52+
import { MongoClient } from 'mongodb'
53+
5054
import Users from './data-sources/Users.js'
5155

56+
const client = new MongoClient('mongodb://localhost:27017/test')
57+
const db = client.db()
58+
5259
const server = new ApolloServer({
5360
typeDefs,
5461
resolvers,

0 commit comments

Comments
 (0)